正确设置request传入内容的编码|set charset encoding properly [Permalink]
Thu Aug 18 11:50:21 CST 2005
request.setCharEncoding("UTF-8")
这句话一定要放在访问request内容之前,否则将不起作用。
原因可能是如果取值之后仍然起作用,会造成设置前后取到的参数编码不一致的情况,而这种情况造成的问题严重性甚于编码出错本身。所以在ServletRequest接口这个方法的API说明中提到:
* Overrides the name of the character encoding used in the body of this * request. This method must be called prior to reading request parameters * or reading input using getReader().
Posted by: miles
Comments on this entry