简体   繁体   English

JSF ISO-8859-2字符集

[英]JSF ISO-8859-2 charset

I have problem with setting proper charset on my jsf pages. 我在jsf页面上设置适当的字符集时遇到问题。 I use MySql db with latin2 (ISO-8859-2 charset) and latin2_croatian_ci collation. 我将MySql db与latin2(ISO-8859-2字符集)和latin2_croatian_ci排序规则一起使用。 But, I have problems with setting values on backing managed bean properties. 但是,我在设置有关支持托管bean属性的值时遇到问题。

Page directive on top of my page is: 页面顶部的Page指令是:

<%@ 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: 我已经使用以下doFilter方法实现在web.xml中创建并注册了Filter:

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, ie when I set managed bean property through inputText, all special (unicode) characters are replaced with '?' 但是,即当我通过inputText设置托管bean属性时,所有特殊(unicode)字符都被替换为'?'。 character. 字符。

I really don't have any other ideas how to set charset to pages to perform well. 我真的没有其他想法如何将字符集设置为良好的页面。 Any suggestions? 有什么建议么?

Thanks in advance. 提前致谢。

The logging I did was misleading. 我所做的记录令人误解。 It turned out that stdout replaced special characters with '?' 原来,stdout用'?'替换了特殊字符。 character. 字符。 But, characters which were written to db were also replaced by '?' 但是,写入db的字符也被替换为'?'。 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. 问题的另一部分是尚未为正确的编码设置JConnector,因此数据库条目看起来非常类似于记录的属性。 I didn't realize that it was a combination of two problems. 我没有意识到这是两个问题的结合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM