Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GWT i18n中的消息方法是否可能过载_Java_Gwt_Internationalization_Overloading - Fatal编程技术网

Java GWT i18n中的消息方法是否可能过载

Java GWT i18n中的消息方法是否可能过载,java,gwt,internationalization,overloading,Java,Gwt,Internationalization,Overloading,我有一个可本地化gwt项目的com.google.gwt.i18n.client.Messages实现 但似乎不可能使方法过载。这是一个错误还是有原因 public interface CommonMessages extends Messages { public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class ); @DefaultMessage( "The entered t

我有一个可本地化gwt项目的
com.google.gwt.i18n.client.Messages
实现

但似乎不可能使方法过载。这是一个错误还是有原因

public interface CommonMessages extends Messages {

    public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );

    @DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
    String textValidatorError( String o, String e );

    @DefaultMessage( "The entered text \"{0}\" contains illegal character(s)." )
    String textValidatorError( String o );
}
提出:

        Rebinding common.client.i18n.CommonMessages
 [java] Invoking generator com.google.gwt.i18n.rebind.LocalizableGenerator
 [java]    Processing interface common.client.i18n.CommonMessages
 [java]       Generating method body for textValidatorError()
 [java]          [ERROR] Argument 1 beyond range of arguments: The entered text "{0}" contains the illegal character(s) "{1}" .

消息接口依赖于属性文件。 因为您的接口有使用相同名称的方法,所以gwt尝试在同一文件中查找属性textValidatorError两次。 它第一次查找具有2个参数的属性,并找到它。第二次,它正在寻找一个具有1个参数的属性,并找到一个具有2个参数的属性。。。因此出现了错误

使用@Key注释指定不同的属性名称

public interface CommonMessages extends Messages {

  public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );

  @DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
  String textValidatorError( String o, String e );

  @DefaultMessage( "The entered text \"{0}\" contains illegal character(s)." )
  @Key("textValidatorErrorAlternate")
  String textValidatorError( String o );
}