java ListResourceBundle检查样式
我正在尝试使用ListResourceBundle对我的web应用进行本地化。它运行良好,但checkstyle显示警告java ListResourceBundle检查样式,java,localization,checkstyle,Java,Localization,Checkstyle,我正在尝试使用ListResourceBundle对我的web应用进行本地化。它运行良好,但checkstyle显示警告 public class Locale_en_US extends ListResourceBundle { @Override protected final Object[][] getContents() { return new Object[][]{ {"Login.Enter-with", "
public class Locale_en_US extends ListResourceBundle {
@Override
protected final Object[][] getContents() {
return new Object[][]{
{"Login.Enter-with", "Enter with"},
{"Login.Hello", "Hello"},
{"Login.Test-Description", "You will have 40 minutes after "
+ "starting test, to finish it"}
};
}
}
使用后:
ResourceBundle resourceBundle = ResourceBundle.getBundle("Locale",request.getLocale());
String testDescr=resourceBundle.getString("Login.Test-Description")
“名称‘Locale_en_US’
必须与模式匹配”^[A-Z][A-zA-Z0-9]*$。
除了更改checkstyle规则集,还有什么办法可以解决这个问题呢?事实上,我找到了解决方案: 我创建了属性文件“Locale_en.properties”,内容如下:
Login.Enter-with=Enter with
Login.Hello=Hello
Login.Test-Description=You will have 40 minutes after starting test to finish it
然后改成
ResourceBundle.getBundle(“/Locale”,request.getLocale())
现在它以同样的方式工作,但不需要使用类
另外,很抱歉我的英语不好。欢迎来到Stack Overflow。我编辑了你的帖子。我用两个星号标记了一个关键字。我使用>标记了您的错误,我认为您需要向我们展示更多的代码、样式表等。您可以添加一些代码吗?我不知道我能帮你什么。