首页 > 代码库 > Servlet中通过过滤器实现统一的手动编码(解决中文乱码)
Servlet中通过过滤器实现统一的手动编码(解决中文乱码)
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://<a href="http://www.mamicode.com/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://www.mamicode.com/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中通过过滤器实现统一的手动编码(解决中文乱码)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。