1

When I visit the URL http://localhost:8080/myapp/search?q=jalape%C3%B1os&p=1 and use request.getParamter("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?!

skaffman
  • 398,947
  • 96
  • 818
  • 769
Zee Spencer
  • 3,460
  • 6
  • 29
  • 31

3 Answers3

4

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.

WeMakeSoftware
  • 9,039
  • 5
  • 34
  • 52
  • So, the answer was a combination of Funtik and Jigar's I modified the Connector and added the useBodyEncodingForURI="true" – Zee Spencer Jan 24 '11 at 17:44
4

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

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
0

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" />
Yahel
  • 8,522
  • 2
  • 24
  • 32