Possible Duplicate:
How to get UTF-8 working in java webapps?
I have a servlet that receives in the request parameter some special characters. I tried to display them, but I o开发者_如何学Pythonnly get question marks instead.
My query string = http://localhost:8080/specialcharacter/quote/startmilesquote?option=côté
I'm displaying
request.getQueryString()
result= option=c%C3%B4t%C3%A9
and
request.getParameter("option")
result=c�t�
I put
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
in the servlet
put <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
in the header of the reponse.
And my connector in server.xml is defined as UTF-8.
<Connector connectionTimeout="20000" port="8080"
protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>
How can I solve my problem?
Make sure the problem is not in displaying, rather than reading:
- if printing on the console, check if the console has UTF-8 encoding
- if storing in the database, make sure the DB connection is set to UTF-8
(Also, make sure you put the request.setCharacterEncoding(..)
before you start using the request)
精彩评论