Miles' Blog

Welcome 2 My Planet

Available categories: [/] [working on downwap.] [trouble shooting] [working on Yup Mailman]

正确设置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





Author (*):
Verify Code (*):8 9 7 9
E-mail:
URL:
Comment (*):
Remember me?

Available categories: [/] [working on downwap.] [trouble shooting] [working on Yup Mailman]

Powered By blojsom   RSS Feed  RSS2 Feed  RDF Feed