资源简介
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
相关资源
- 基于Filter-Hook Driver的个人防火墙
- crossfilter tutorial
- Tracking and Kalman Filtering Made Easy
- 利用ffmpeg的filter混音
- 国内首家采用MS全新 MiniFilter架构的
- 容积卡尔曼滤波(CKF)和嵌入式容积
- 低通滤波器设计软件(FilterLab) v2.
- 好用滤波器设计软件 Filter Wiz pro 3.2
- JULIUSO. SMITHIII《INTRODUCTION TO DIGITAL FI
- Filter Wiz PRO 3.2破解版滤波器软件
- stereo matching using tree filtering
- Microstrip Filters for RF Microwave Applicatio
- LAVFilters-0.68.1安装.rar
- Introduction_To_Digital_Signal_Processing_And_
- Adaptive Filters: Theory and Applications-2nd
- Gradient Domain Guided Image Filtering
- 何凯明引导滤波去雾算法
- 灰度图像的中值滤波算法verilog实现
- CAN_Filter_Test
- 双边滤波opencv实现
- Adobe Audition3.0扩展编码器 Audition3.0Fi
- FilterLab 2.0使用手册(pdf)
- Microstrip Filters for RF Microwave Applicatio
- Introduction-to-Digital-Filters-with-Audio-App
- ECCV10-Guided Image Filter-代码
- ECCV10-Guided Image Filter -ppt
- 二阶锁频辅助三阶锁相环路滤波器设
- 自适应滤波器原理第五版英文答案S
- Fundamentals of Kalman Filtering: A Practical
- Instagram Filters 破解了Instagram App的几十
评论
共有 条评论