struts2乱码

1:编写过滤器类characterEncodingFilter实现Filter接口, 在doFilter(ServletRequest request,ServletResponse response,FilterChain chain)方法中 加入代码 request.setcharacterEncoding("utf-8"); chain.doFilter(request,response);

2:在web-xml中加入代码    <filter>

        <filter-name>characterEncoding</filter-name>
        <filter-class>com.clannan.filter.CharacterEncodingFilter</filter-class>

    </filter>

       <filter-mapping>
       <filter-name>characterEncoding</filter-name>
       <url-pattern>/*</url-pattern>
    </filter-mapping>

搞定

你可能感兴趣的:(struts2乱码)