myeclipse 创建一个验证是否登录的过滤器
来源:互联网 发布:淘宝网首页包包 编辑:程序博客网 时间:2024/05/14 15:04
1、首先,在myeclipse中创建一个过滤器(filter)
创建方法:
右键“new-filter”,如果没有filter选项,点击other选项后,在搜索框中输入filter,如图:
2、创建成功后,在过滤器中创建函数实现登录验证
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub // 过滤行为 HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; // 用户登录验证 String account = (String) httpRequest.getSession().getAttribute("tLogin"); // 如果没有登录,跳转到登录页面 if (account == null) { httpResponse.sendRedirect("/front/frontlogin.jsp"); } else{ // 验证通过,放行 chain.doFilter(request, response); } }
3、配置xml文件
filter文件并不像servlet创建后会自动配置xml文件,所以需要手动配置xml文件。
<filter> <filter-name>FrontFilter</filter-name> <filter-class>com.eams.filter.FrontFilter</filter-class> </filter> <filter-mapping> <filter-name>FrontFilter</filter-name> <url-pattern>/front/teacher/*</url-pattern> </filter-mapping>
0 0
- myeclipse 创建一个验证是否登录的过滤器
- 用户是否登录验证--过滤器
- 创建用户登录的过滤器
- 如何给登录页面添加一个验证是否是机器登录的方式(验证码)
- javaweb的登录验证过滤器的实现
- 过滤器Filter的应用:登录验证
- jsp实现登录验证的过滤器
- 登录验证过滤器
- 过滤器验证登录
- filter过滤器登录验证
- 统一登录验证过滤器
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- 过滤器检验用户是否登录
- Java web登录验证过滤器
- JSP登录验证编码过滤器
- 使用过滤器做登录验证
- 使用FindBugs-IDEA插件找到代码中潜在的问题
- 全志H3平台DMA框架
- Yii基于RBAC的权限系统
- 浅谈协方差矩阵-统计学的基本概念
- 互联网的来袭,产品的丰富,电商如何确立何为好产品[太原网络营销师]详解
- myeclipse 创建一个验证是否登录的过滤器
- ROS, the Robot Operating System, Is Growing Faster Than Ever, Celebrates 8 Years
- 转~~是否有朋友能对LS,MMSE,LMMSE,ML,MAP,LMS,AR
- JVM内存分析及导致内存溢出的不健壮代码及解决办法
- android 获取图片的长度和宽度
- 知乎问答-如何做一个软件需求分析师
- MyEclipse如何生成javadoc
- c++课程心得体会
- MMSE信道估计方法 LS信道估计