|
发表于 2020-2-19 23:15:01
|
显示全部楼层
编译这个类
package com.group;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class EncodingFilter implements Filter{
public void init(FilterConfig filterConfig)
throws ServletException{
}
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws java.io.IOException,ServletException{
request.setCharacterEncoding("GBK");
chain.doFilter(request,response);
}
public void destroy(){
}
}
然后在web-xml里添加
<filter>
<filter-name>encode</filter-name>
<filter-class>com.group.EncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>encode</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
这样就可以是等到的编码集变成中文了,应该就 可以解决你的问题了 |
|