字符 过滤
大家好:我想请教的问题是:
为了处理乱码问题 我写了个过滤器,设置字符编码为来处理htm提交的form表单,但是就是不起作用;我想请问是怎么回事情啊?
过滤代码如下:
package global;
import
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class EncodingFilter implements Filter {
protected FilterConfig filterConfig;
public void init(FilterConfig config) throws ServletException {
this.filterConfig = config;
}
public void doFilter(final ServletRequest req, final ServletResponse res,
FilterChain chain) throws IOException, ServletException {
req.setCharacterEncoding("gb2312");
chain.doFilter(req, res);
}
public void destroy() {
this.filterConfig = null;
}
}