JSF ISO-8859-2 charset

烈酒焚心 提交于 2019-12-11 04:38:18

问题


I have problem with setting proper charset on my jsf pages. I use MySql db with latin2 (ISO-8859-2 charset) and latin2_croatian_ci collation. But, I have problems with setting values on backing managed bean properties.

Page directive on top of my page is:

<%@ page language="java" pageEncoding="ISO-8859-2" contentType="text/html; charset=ISO-8859-2" %>

In head I included:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">

And my form tag is:

<h:form id="entityDetails" acceptcharset="ISO-8859-2">

I've created and registered Filter in web.xml with following doFilter method implementation:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    request.setCharacterEncoding("ISO-8859-2");
    response.setCharacterEncoding("ISO-8859-2");
    chain.doFilter(request, response);
}

But, i.e. when I set managed bean property through inputText, all special (unicode) characters are replaced with '?' character.

I really don't have any other ideas how to set charset to pages to perform well. Any suggestions?

Thanks in advance.


回答1:


The logging I did was misleading. It turned out that stdout replaced special characters with '?' character. But, characters which were written to db were also replaced by '?' sign. The other part of the problem was that JConnector hasn't been set for correct encoding, so db entries looked very much like logged properties. I didn't realize that it was a combination of two problems.



来源:https://stackoverflow.com/questions/2661810/jsf-iso-8859-2-charset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!