码迷,mamicode.com
首页 > 其他好文 > 详细

fifter过滤器

时间:2017-01-04 08:42:27      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:username   nbsp   ati   exception   pack   void   string   ram   过滤   

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()");
}

}

fifter过滤器

标签:username   nbsp   ati   exception   pack   void   string   ram   过滤   

原文地址:http://www.cnblogs.com/javaweb2/p/6247254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!