Liny_@NotePad

沉迷ACG中

修改Tomcat默认编码

YOYO posted @ 2009年8月07日 09:46 in 【工具/OS】 with tags tomcat 编码 , 28439 阅读

实际项目中一般是用utf-8的,而Tomcat的默认编码则是iso-8859-1

因此我们通常编辑conf/下的server.xml,配置Connector项,加上属性URIEncoding="UTF-8"即可。

hy 说:
2010年2月23日 07:40

这个只能解决get方式的 post方式还是需要用到request.setCharacterEncoding("utf-8");

YOYO 说:
2010年2月23日 20:32

@hy: (⊙o⊙)原来都没注意…学到了…的确在tomcat的说明中指出了URIEncoding:This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.

www.eyny.cn 说:
2013年9月30日 20:48

String title = new String(request.getParameter("title").getBytes("ISO-8859-1"),"UTF-8"); 在servlet中使用这种方法可以讲post的中文转码成 UTF-8


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter