问题
I have a problem reading request paremeters from a GET request that contain special characters. Here's what I do:
I create the request url with javascript, and the value of drivername is encodeURIComponent('sorumluluğumuzu') The result is this URL, which shows up correctly in firefox: http://localhost:8080/driver/list.xhtml?sl=1&drivername=sorumlulu%C4%9Fumuzu
However, when I read the request param in my JSF bean: FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
The value equals to sorumluluÄumuzu
I'm experiencing this om Tomcat7 in JSF2, but we are noticing the same issue on Websphere6 and JSF1.2.
Any thoughts?
回答1:
Tomcat by default URL-decodes GET request parameters using ISO-8859-1. You need to change it to UTF-8 by the URIEncoding attribute in the <Connector> element of Tomcat's /conf/server.xml.
<Connector ... URIEncoding="UTF-8">
See also:
- Unicode - How to get the characters right? - JSP/Servlet request
来源:https://stackoverflow.com/questions/6427689/reading-request-parameter-values-with-utf-8-chars-in-jsf