public class DoFilter implements Filter{
private String encode;
private String enable;
public void destroy() {
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
if("true".equalsIgnoreCase(enable)){
//过滤器启动
System.out.println("启动过滤器");
req.setCharacterEncoding(encode);
}
chain.doFilter(req, res);
}
public void init(FilterConfig config) throws ServletException {
encode=config.getInitParameter("encode");
enable=config.getInitParameter("enable");
System.out.println("encode="+encode);
System.out.println("enable="+enable);
}
private String encode;
private String enable;
public void destroy() {
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
if("true".equalsIgnoreCase(enable)){
//过滤器启动
System.out.println("启动过滤器");
req.setCharacterEncoding(encode);
}
chain.doFilter(req, res);
}
public void init(FilterConfig config) throws ServletException {
encode=config.getInitParameter("encode");
enable=config.getInitParameter("enable");
System.out.println("encode="+encode);
System.out.println("enable="+enable);
}