码迷,mamicode.com
首页 > 其他好文 > 详细

Servlet中通过过滤器实现统一的手动编码(解决中文乱码)

时间:2016-10-10 13:26:50      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

        <?xml version="1.0" encoding="UTF-8"?>  
        <web-app version="2.4" xmlns="http://<a href="http://lib.csdn.net/base/javaee" class=‘replace_word‘ title="Java EE知识库" target=‘_blank‘ style=‘color:#df3434; font-weight:bold;‘>Java</a>.sun.com/xml/ns/j2ee"  
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   
            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
            <servlet>  
                <servlet-name>test</servlet-name>  
                <servlet-class>selfimpr.web.encoding.test.TestServlet</servlet-class>  
                <load-on-startup>1</load-on-startup>  
            </servlet>  
            <servlet-mapping>  
                <servlet-name>test</servlet-name>  
                <url-pattern>/servlet/test</url-pattern>  
            </servlet-mapping>  
            <filter>  
                <filter-name>parameterEncoding</filter-name>  
                <filter-class>selfimpr.web.encoding.test.ParameterEncodingFilter</filter-class>  
                <init-param>  
                    <param-name>oldEncoding</param-name>  
                    <param-value>ISO8859-1</param-value>  
                </init-param>  
                <init-param>  
                    <param-name>newEncoding</param-name>  
                    <param-value>GBK</param-value>  
                </init-param>  
            </filter>  
            <filter-mapping>  
                <filter-name>parameterEncoding</filter-name>  
                <url-pattern>/*</url-pattern>  
            </filter-mapping>  
            <welcome-file-list>  
                <welcome-file>index.jsp</welcome-file>  
            </welcome-file-list>  
        </web-app> 

        <?xml version="1.0" encoding="UTF-8"?>  
        <web-app version="2.4" xmlns="http://<a href="http://lib.csdn.net/base/javaee" class=‘replace_word‘ title="Java EE知识库" target=‘_blank‘ style=‘color:#df3434; font-weight:bold;‘>Java</a>.sun.com/xml/ns/j2ee"  
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   
            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
            <servlet>  
                <servlet-name>test</servlet-name>  
                <servlet-class>selfimpr.web.encoding.test.TestServlet</servlet-class>  
                <load-on-startup>1</load-on-startup>  
            </servlet>  
            <servlet-mapping>  
                <servlet-name>test</servlet-name>  
                <url-pattern>/servlet/test</url-pattern>  
            </servlet-mapping>  
            <filter>  
                <filter-name>parameterEncoding</filter-name>  
                <filter-class>selfimpr.web.encoding.test.ParameterEncodingFilter</filter-class>  
                <init-param>  
                    <param-name>oldEncoding</param-name>  
                    <param-value>ISO8859-1</param-value>  
                </init-param>  
                <init-param>  
                    <param-name>newEncoding</param-name>  
                    <param-value>GBK</param-value>  
                </init-param>  
            </filter>  
            <filter-mapping>  
                <filter-name>parameterEncoding</filter-name>  
                <url-pattern>/*</url-pattern>  
            </filter-mapping>  
            <welcome-file-list>  
                <welcome-file>index.jsp</welcome-file>  
            </welcome-file-list>  
        </web-app> 

 





 

Servlet中通过过滤器实现统一的手动编码(解决中文乱码)

标签:

原文地址:http://www.cnblogs.com/zdd-java/p/5945236.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!