When I visit the URL http://localhost:8080/myapp/search?q=jalape%C3%B1os&p=1 and use request.getPa开发者_运维技巧ramter("q") the string becomes jalapeños instead of jalapeños. Obviously this is a problem.
I'm running Spring 3 with tomcat, everything "says" it's coming through as UTF8; which means it should be rendering as jalapeños.
Help?!
Check the tomcat's encoding. According to the Servlet spec (see http://wiki.apache.org/tomcat/FAQ/CharacterEncoding) the default one is not UTF-8, but ISO-8859-1
Also take a look at http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q3 . This might well solve your issues.
You need to configure tomcat something like this
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="on"
compressionMinSize="128"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
URIEncoding="UTF-8"
/>
Note: URIEncoding UTF8
Also See
- encoding-problem-in-servlet
The only reason possible is a UTF8 misconfiguration in your software chain.
Recheck :
- Server configuration for this host
- Spring configuration
- Java Config for the web application
- And of course your meta data in the head of the webpage :
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
精彩评论