[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
Category [development. ~]

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 [0] |

?
三月 2024
Sun? Mon? Tue? Wed? Thu? Fri? Sat?
     12
3456789
10111213141516
17181920212223
24252627282930
31      
<  Feb???Today??? Apr  >
<< <   1   > >>

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

Powered By blojsom?? RSS Feed? RSS2 Feed? RDF Feed

html hits:?38637