java - face-config 默认需要消息覆盖编码
问题描述
我有一个使用多种语言的多语言项目,我创建了一个 UTF8-Control,我在我的 face-config.xml 中定义,它适用于所有语言的 .properties 文件。
然后我覆盖 javax.faces.component.UIInput.REQUIRED = {0} wird benötigt。在 UI 中,当我需要德语所需的消息时,我会收到名称 wird benö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;
}}
解决方案
推荐阅读
- android - java.lang.IllegalStateException: WorkManager 已经初始化。即使工作管理器未初始化
- google-pay - 在 Google 支付网关中没有可用于此商家的可接受的卡
- three.js - React-three-fiber extrudeBufferGeometry 不受灯光影响
- c# - c#文件夹的getFiles上的“系统调用级别不正确”
- java - 为了用户输入的错误响应?
- reactjs - 当: { props } = this 是什么意思
- javascript - 图像的相对路径受到 routify 中嵌套路由的影响
- c - 使用 C 生成 Mandlebrot 集 (DISLIN)
- kubernetes - 为什么即使节点关闭,Pod 仍显示正在运行?
- pine-script - 策略关闭 pinescript