1

我有一个只有一个字段的表格。当我提交表单时,我的字段值变得奇怪。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
4

1 回答 1

3

我也有同样的问题。

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

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

于 2012-04-25T11:34:44.510 回答