1.在tomcat6/conf/server.xml
中<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
2.在对应的应用中添加字符过滤器
继承 javax.servlet.Filter
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
chain.doFilter(request, response);
}
3.在对应的应用中web.xml中添加过滤器
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>cn.ywj.webexample.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
posted on 2008-08-13 14:33
poower 阅读(162)
评论(0) 编辑 收藏 所属分类:
j2ee学习笔记