Java GWT i18n中的消息方法是否可能过载
我有一个可本地化gwt项目的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
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 );
}