3,jsp到HttpServletRequest request控制台乱码,使用过虑字符
3.1创建一个工具类
public class CharFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("utf-8");//设置中文编码
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
3.在WEB-INT的web.xml的<web-app>2</web-app>中配制
<filter>
<!-- 指定过虑器的名字,自取-->
<filter-name>chaiFilter</filter-name>
<!-- 过虑所在文件类全路径-->
<filter-class>com.snow.util.CharFilter</filter-class>
</filter>
<filter-mapping>
<!-- 名字和上自取一样-->
<filter-name>chaiFilter</filter-name>
<!-- 范围 -->
<url-pattern>/*</url-pattern>
</filter-mapping>
jsp页面
<form action="admin/updateOne" method="post">
</from>一定要用POST提交才可才
3.1创建一个工具类
public class CharFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("utf-8");//设置中文编码
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
3.在WEB-INT的web.xml的<web-app>2</web-app>中配制
<filter>
<!-- 指定过虑器的名字,自取-->
<filter-name>chaiFilter</filter-name>
<!-- 过虑所在文件类全路径-->
<filter-class>com.snow.util.CharFilter</filter-class>
</filter>
<filter-mapping>
<!-- 名字和上自取一样-->
<filter-name>chaiFilter</filter-name>
<!-- 范围 -->
<url-pattern>/*</url-pattern>
</filter-mapping>
jsp页面
<form action="admin/updateOne" method="post">
</from>一定要用POST提交才可才