JSF ISO-8859-2字符集 [英] JSF ISO-8859-2 charset

查看:194
本文介绍了JSF ISO-8859-2字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的jsf页面上设置正确的字符集有问题。我使用MySql数据库与latin2(ISO-8859-2字符集)和latin2_croatian_ci排序规则。但是,对于在托管托管bean属性上设置值,我有问题。

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" %>

在标题中包括:

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

我的表单标签是:

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

我已经创建并注册了在web.xml中的Filter,并使用下面的doFilter方法实现:

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?

提前感谢。

推荐答案

确实是误导。原来,stdout用?字符替换了特殊字符。但是,写入db的字符也被替换为'?'符号。问题的另一部分是JConnector没有设置为正确的编码,所以db条目看起来非常像日志属性。我没有意识到这是两个问题的组合。

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.

这篇关于JSF ISO-8859-2字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆