Facelets字符集问题 [英] Facelets charset problem

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

问题描述

在我的较早的帖子中,存在JSF字符集处理的问题,另一部分的问题是用于将数据插入到db中的MySQL连接参数。问题解决了。

In my earlier post there was a problem with JSF charset handling, but also the other part of the problem was MySQL connection parameters for inserting data into db. The problem was solved.

但是,我将相同的应用程序从JSP迁移到facelets,同样的问题再次发生。在插入到数据库时,输入字段中的字符将被替换(č由Ä替换),但是使用正确字符集从sql脚本插入到db中的数据会正确显示。我仍然使用注册过滤器和页面模板使用头元标记如下:

But, I migrated the same application from JSP to facelets and the same problem happened again. Characters from input fields are replaced when inserting to database (č is replaced with Ä), but data inserted into db from sql scripts with proper charset are displayed correctly. I'm still using registered filter and page templates are used with head meta tag as following:

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

如果我在h:form标签中插入以下属性:

If I insert into h:form tag the following attribute:

acceptcharset="iso-8859-2"

我在Firefox中获得正确的字符,但在IE7中不正确。

I get correct characters in Firefox, but not in IE7.

还有什么我应该做的工作吗?

Is there anything else I should do to make it work?

提前感谢。

推荐答案

将以下行添加到过滤器:

Add the following line to the filter:

response.setContentType("text/html;charset=ISO-8859-2");

不要使用 acceptcharset 属性。

此外,当您使用<?xml?> 在Facelets XHTML页面顶部声明,确保它使用所需的字符集或只删除整个声明,它不是严格要求。

Also, when you're using a <?xml?> declaration in top of Facelets XHTML page, ensure that it's using the desired charset or just remove the whole declaration, it's not strictly required.

<?xml version="1.0" encoding="ISO-8859-2"?>

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

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