资源简介
Filter使用范例--登陆验证,具体效果和过程看博文
http://blog.csdn.net/evankaka/article/details/45480101
代码片段和文件信息
package com.mucfc;
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.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
* 权限过滤器
*
* */
public class AuthorityFilter implements Filter {
private FilterConfig config;
@Override
public void destroy() {
this.config=null;
}
@Override
public void doFilter(ServletRequest request ServletResponse response
FilterChain chain) throws IOException ServletException {
//获取Filter配置参数
String encoding=config.getInitParameter(“encoding“);
String loginPage=config.getInitParameter(“loginPage“);
String afterLogin=config.getInitParameter(“afterLogin“);
//设置request编码
request.setCharacterEncoding(encoding);
HttpServletRequest requ=(HttpServletRequest) request;
HttpSession session=requ.getSession();
//获取客户请求页面
String requestPath=requ.getServletPath();
String name=requ.getParameter(“username“);
if(name==““||name==null){
System.out.println(“权限拦截器的消息:“+“终止“);
HttpServletResponse resq=(HttpServletResponse)response;
resq.sendRedirect(requ.getContextPath()+loginPage);
}else{
System.out.println(“权限拦截器的消息:“+“放行“);
request.setCharacterEncoding(“UTF-8“);
chain.doFilter(request response);
}
}
@Override
public void init(FilterConfig config) throws ServletException {
this.config=config;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\
文件 841 2015-05-04 16:33 ServletLearningChapter2_2\.classpath
文件 1058 2015-05-04 16:33 ServletLearningChapter2_2\.project
目录 0 2015-05-04 16:41 ServletLearningChapter2_2\.settings\
文件 503 2015-05-04 16:33 ServletLearningChapter2_2\.settings\.jsdtscope
文件 106 2015-05-04 16:44 ServletLearningChapter2_2\.settings\org.eclipse.core.resources.prefs
文件 364 2015-05-04 16:33 ServletLearningChapter2_2\.settings\org.eclipse.jdt.core.prefs
文件 527 2015-05-04 16:33 ServletLearningChapter2_2\.settings\org.eclipse.wst.common.component
文件 345 2015-05-04 16:33 ServletLearningChapter2_2\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2015-05-04 16:33 ServletLearningChapter2_2\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-05-04 16:33 ServletLearningChapter2_2\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\build\
目录 0 2015-05-17 13:48 ServletLearningChapter2_2\build\classes\
目录 0 2015-05-17 13:48 ServletLearningChapter2_2\build\classes\com\
目录 0 2015-05-17 13:48 ServletLearningChapter2_2\build\classes\com\mucfc\
文件 2663 2015-05-17 13:48 ServletLearningChapter2_2\build\classes\com\mucfc\AuthorityFilter.class
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\src\
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\src\com\
目录 0 2015-05-04 16:34 ServletLearningChapter2_2\src\com\mucfc\
文件 1897 2015-05-04 18:35 ServletLearningChapter2_2\src\com\mucfc\AuthorityFilter.java
目录 0 2015-05-04 16:41 ServletLearningChapter2_2\WebContent\
文件 567 2015-05-04 18:31 ServletLearningChapter2_2\WebContent\Login.jsp
文件 519 2015-05-04 17:32 ServletLearningChapter2_2\WebContent\Main.jsp
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\WebContent\me
文件 39 2015-05-04 16:33 ServletLearningChapter2_2\WebContent\me
目录 0 2015-05-04 16:40 ServletLearningChapter2_2\WebContent\WEB-INF\
目录 0 2015-05-04 16:33 ServletLearningChapter2_2\WebContent\WEB-INF\lib\
文件 1086 2015-05-04 18:42 ServletLearningChapter2_2\WebContent\WEB-INF\web.xm
相关资源
- 100HZ~10K频率测试音源
- 源码图像去噪-lee filter.rar
- Sallen Key拓扑电路
- 线性调频信号的压缩以及加窗处理
- 文件内容检索工具 filefilter 1.0
- TI滤波器仿真filterpro链接.txt
- an economical class of digital filters for dec
- digital filter基流分割
- kalman filtering in R(R语言实现卡尔曼滤
- bloomFilter 中的hash函数及测试程序
- 翻转图像的Transform Filter
- UnifiedWriteFilter(uwf)
- 差分输入ADC的前端抗混叠RC滤波器设计
- MacFilterCalloutInstaller
- PSCAD中的微电网光伏发电MPPT最大功率
- SincFilter
- miniFilter(所有框架代码以及对应的
- Improved Sigma Filter for Speckle
- NormalMapFilter.8bf
- sailencyFilter 可以编译的源码
- H3C华三 SecPath防火墙webdata-filter典型组
- zw_BloomFilter.zip
-
Item ba
sed collaborative filtering recommen - windows内科安全与驱动开发,minifilte
- ebtables-v2.0.10-4.tar.gz
- 卡尔曼滤波工具箱(kalman filter box)
- 简单的个人防火墙源码
- minifilter 文件透明加密源码
- SVPWM_RCFilter.slx
- Introduction to Digital Filters
评论
共有 条评论