2015-10-22 28 views
-1

我正在尝试使用ListResourceBundle来本地化我的web应用程序。它运作良好,但CheckStyle的显示警告java ListResourceBundle checkstyle

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") 

"Name 'Locale_en_US''^[A-Z][a-zA-Z0-9]*$'.".

是哪里来解决这个问题的任何方式,只是改变的CheckStyle规则集必须匹配模式?

+0

欢迎来到Stack Overflow。我编辑了你的帖子。我用两个星号标记了一个关键字。我用> 来标记你的错误我想你需要向我们展示更多的代码,样式表等。 –

+0

你能添加一些代码吗?我不知道我能帮你什么。 –

回答

0

其实,我找到解决办法: 我创建的属性文件 “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(“/区域设置”,请求.getLocale())

现在它以相同的方式工作,但它不需要使用类。

P.S.对不起我的英文破碎。