开发者

Encoding in JSF 2 + Tomcat 7

开发者 https://www.devze.com 2023-04-09 22:13 出处:网络
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.

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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消