在我的應用程序中,我使它具有兩種語言。英文和法文。 英文,好吧。但在閱讀法文語言的屬性文件時,它最終會顯示mojibake。 我有我的屬性文件是這樣的: example.french.char=é
JSF-primefaces中的法語字符應用程序顯示Mojibake
但它不能正常顯示在應用程序中。我正在Windows中查看我的應用程序。我不想用Unicode字符替換法文字符。我希望它們能夠像通常顯示的那樣從屬性文件中讀取。
我該如何讓它工作? 請建議。我可以在不使用Unicodes的情況下查看法語字符嗎?
我的屬性文件使用UTF-8編碼。 請建議!
我嘗試以下太..
public class CharacterEncodingFilter implements Filter{
private FilterConfig config;
@Override
public void destroy() {
setConfig(null);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filter) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
filter.doFilter(request, response);
}
@Override
public void init(FilterConfig config) throws ServletException {
setConfig(config);
}
public FilterConfig getConfig() {
return config;
}
public void setConfig(FilterConfig config) {
this.config = config;
}
}
,並在web.xml
<filter>
<filter-name>charEncoding_Filter</filter-name>
<filter-class>com.edfx.tum.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>charEncoding_Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
添加了這個但仍顯示變爲亂碼。
他也可以在JSF 2.X中使用註釋。 ('@WebFilter ...') –
@britulin:是的,我也試過。但沒有幫助!請參閱我的修改。 – NDeveloper