Facelets字符集问题

编程入门 行业动态 更新时间:2024-10-28 01:14:33
本文介绍了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字符集问题

本文发布于:2023-05-27 19:05:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/299878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符集   Facelets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!