我有一个使用多种语言的多语言项目,我创建了一个UTF8控件,该控件在face-config.xml中定义,可以与我的.properties文件对所有语言正常工作。
然后我将覆盖javax.faces.component.UIInput.REQUIRED = {0}与benötigt。 在UI中,当我需要德语所需的消息时,我会收到名字wirdbenötigt。
此问题仅在我尝试使用自定义消息替代(如
)时出现javax.faces.component.UIInput.CONVERSION javax.faces.converter.DateTimeConverter.DATE_detail
这给我的印象是我的UT8Control不在转换此文本时使用(当我尝试调试时也是如此)
我的UTF8Control类在这里
public class UTF8Control extends ResourceBundle.Control {
@Override
public ResourceBundle newBundle
(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
throws IllegalAccessException, InstantiationException, IOException
{
// The below is a copy of the default implementation.
String bundleName = toBundleName(baseName, locale);
String resourceName = toResourceName(bundleName, "properties");
ResourceBundle bundle = null;
InputStream stream = null;
if (reload) {
URL url = loader.getResource(resourceName);
if (url != null) {
URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
stream = connection.getInputStream();
}
}
} else {
stream = loader.getResourceAsStream(resourceName);
}
if (stream != null) {
try {
// Only this line is changed to make it to read properties files as UTF-8.
bundle = new PropertyResourceBundle(new InputStreamReader(stream, UTF_8));
} finally {
stream.close();
}
}
return bundle;
}
@Override
public Locale getFallbackLocale(String name,
Locale locale) {
// see super @return description. Return null for no fallback locale
return null;
}}