【发布时间】:2011-09-30 14:51:52
【问题描述】:
我有一个只有一个字段的表单。当我提交表单时,我的字段值变得奇怪。 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
【问题讨论】:
-
“Extremação 这个词变成了 Extremação。” 你到底在哪里检查值?在数据库中?或者在你的IDE中通过
System.out.println()?或者在浏览器的结果页面中?您使用的是 JSP 还是 Facelets? -
您已经编辑了您的帖子,但您没有对我的上述评论提供任何反馈。为什么?你不想帮助我们帮助你吗?
-
我正在检查我的 IDE 中的值(setter 方法)。我正在使用 facelets。
-
哪个 IDE?蚀?你是怎么检查的?通过
System.out.println()或在调试器变量视图中?提交后网页浏览器中的值如何? -
HTTP 响应的
Content-Type标头的值是多少? (您只显示了 HTTP 请求标头)。你使用的是什么浏览器? MSIE 与acceptcharset存在重大问题。
标签: character-encoding jsf-2 tomcat7 content-encoding