struts1.2中处理中文乱码问题

来源:互联网 发布:淘宝直播系统抽奖连击 编辑:程序博客网 时间:2024/05/11 02:36

在struts1.2中如何处理中文乱码问题呢?直接写个过滤器最方便。

过滤器代码:

public class EncodingFilter implements Filter {

 public void destroy() {
 }

 public void doFilter(ServletRequest request, ServletResponse response,
   FilterChain chain) throws IOException, ServletException {
  request.setCharacterEncoding("GBK"); // GBK编码格式
   chain.doFilter(request, response);
 }

 public void init(FilterConfig filterConfig) throws ServletException {
 }

}

原创粉丝点击