package fifter;
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;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
@WebFilter("/login")
public class TestFifer implements Filter {
public void destroy() {
System.out.println("TestFifer.destroy()");
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
String name=req.getParameter("username");
System.out.println(name);
System.out.println("TestFifer.doFilter()1");
chain.doFilter(request, response); //当有这个时,过滤器主动放行
System.out.println("TestFifer.doFilter()2");
}
public void init(FilterConfig fConfig) throws ServletException {
System.out.println("TestFifer.init()");
}
}