用户是否登录验证--过滤器
来源:互联网 发布:网络无线机顶盒接收器 编辑:程序博客网 时间:2024/05/18 02:24
用户是否登录验证--过滤器
public class AuthenticationFilter implements Filter {
String url="/";
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
HttpServletResponse res=(HttpServletResponse )response;
HttpSession session=req.getSession();
if(session.getAttribute("User")==null){
res.sendRedirect(req.getContextPath()+url);
return;
}
chain.doFilter(request,response);
}
public void init(FilterConfig config) throws ServletException {
url=config.getInitParameter("url");
}
}
web.xml
<filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>com.util.AuthenticationFilter</filter-class>
<init-param>
<param-name>url</param-name>
<param-value>/admin/login.jsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/admin/secure/*<url-pattern> /*添加删除更新代码都放在该路径下面*/
</filter-mapping>
- 用户是否登录验证--过滤器
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- 用过滤器判断用户是否已经登录
- 过滤器(filter)判断用户是否登录
- JSP中filter过滤器验证用户登录
- 使用Servlet过滤器实现用户登录验证
- 使用Servlet过滤器实现用户登录验证
- JSP中filter过滤器验证用户登录
- JSP中filter过滤器验证用户登录(
- 使用filter过滤器实现用户登录验证
- 用过滤器验证用户登录功能
- .net mvc 中的用户登录验证过滤器
- struts 过滤器验证用户是否已经登陆
- 过滤器篇(1)-----用户登录验证过滤器(LoginFilter)
- 用户登录及验证用户是否登录的代码
- my string.js
- C++中定义与声明的区别
- 搭建Windows驱动程序设计环境(Windows XP + VC 6.0 + WinXP_DDK + DriverStudio 3.2 )
- An article about Equals and GetHashCode functions in C#
- 网络爬虫调研报告
- 用户是否登录验证--过滤器
- 10个CSS简写技巧让你永远受用
- 线性表的链式表示与实现
- 一个简单程序的分析----深至内核
- 直播星升级:造福渠道,用户遭殃
- An article about Equals and GetHashCode functions in C#
- 《世界因你不同》——去微软,回中国
- 网络爬虫-Heritrix 和 Nutch比较与分析
- 注册表的文件类型关联[转]