JSF 2 中的编码雄猫7
我有一张表格,只有一个字段。当我提交表单时,我的字段的值变得很奇怪。 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有同样的问题。
最后我找到了这个错误的解决方案。您应该创建一个过滤器来显示非 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/