如何在eclipse中,通过向导来创建Filter(该Filter会自动在web.xml中部署)?
请哪位朋友帮忙解决!谢谢。。
------解决方案--------------------
import java.io.IOException;
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 {
public void destroy() {
// TODO 自动生成方法存根
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO 自动生成方法存根
try{
request.setCharacterEncoding( "UTF-8 ");
chain.doFilter(request, response);
}
catch(Exception ex){
ex.printStackTrace();
}
}
public void init(FilterConfig arg0) throws ServletException {
// TODO 自动生成方法存根
}
}
------解决方案--------------------
帮顶!