Reading request parameter values with UTF-8 chars in JSF

本秂侑毒 提交于 2019-12-11 03:36:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!