JSF 2 中的编码雄猫7

发布于 2024-12-07 04:13:42 字数 1255 浏览 0 评论 0原文

我有一张表格,只有一个字段。当我提交表单时,我的字段的值变得很奇怪。 Extremação 一词变为 Extremação。

因此,我已经在应用程序的每个位置设置了 UTF-8 编码:

<?xml version="1.0" encoding="UTF-8"?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<f:view contentType="text/html" encoding="UTF-8">
<h:form id="formParamSupremo"  prependId="false" acceptcharset="UTF-8">

我也创建了一个编码过滤器:

request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");

我的 http 标头如下所示:

host = localhost:8080
user-agent = Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.9.2.23) Gecko/20110921
user-agent = Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.9.2.23) Gecko/20110921        Ubuntu/10.04 (lucid) Firefox/3.6.23
accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language = pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
accept-encoding = gzip,deflate
accept-charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive = 115
connection = keep-alive
referer = http://localhost:8080/parametros/view/xhtml/parametrosSupremo.jsf
cookie = JSESSIONID=6DC0C1D4434FB90C3F9271D6C54DC575
content-type = application/x-www-form-urlencoded
content-length = 185

I have one form with only one single field. When I submit the form, the value of my field becomes strange. The word Extremação becomes Extremação.

So, I already set UTF-8 encoding in every place on my app:

<?xml version="1.0" encoding="UTF-8"?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<f:view contentType="text/html" encoding="UTF-8">
<h:form id="formParamSupremo"  prependId="false" acceptcharset="UTF-8">

I created one encoding filter too:

request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");

And my http header is like this:

host = localhost:8080
user-agent = Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.9.2.23) Gecko/20110921
user-agent = Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.9.2.23) Gecko/20110921        Ubuntu/10.04 (lucid) Firefox/3.6.23
accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language = pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
accept-encoding = gzip,deflate
accept-charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive = 115
connection = keep-alive
referer = http://localhost:8080/parametros/view/xhtml/parametrosSupremo.jsf
cookie = JSESSIONID=6DC0C1D4434FB90C3F9271D6C54DC575
content-type = application/x-www-form-urlencoded
content-length = 185

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话 2024-12-14 04:13:42

我有同样的问题。

最后我找到了这个错误的解决方案。您应该创建一个过滤器来显示非 ascii 字符。多么烦人的错误:(

http://dertompson. com/2007/01/29/encoding-filter-for-java-web-applications/

I have the same problem.

Finally I found this error solutions. You should create a Filter to display non ascIi characters. What an annoying bugs :(

http://dertompson.com/2007/01/29/encoding-filter-for-java-web-applications/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文