日期:2014-05-17 浏览次数:20807 次
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterchain)
throws ServletException, IOException {
// 不过滤的uri
String[] notFilter = new String[] { "login.jsp","login","plui","include",".css","testLoginServlet" };
// 请求的uri
String uri = request.getRequestURI();
// uri中包含plattutor3时才进行过滤
if (uri.indexOf("plattutor3") != -1) {
// 是否过滤
boolean doFilter = true;
for (String s : notFilter) {
if (uri.indexOf(s) != -1) {
// 如果uri中包含不过滤的uri,则不进行过滤
System.out.println("session filter 不过滤__________");
doFilter = false;
break;
}
}
if (doFilter) {
if(request.getSession(false)==null){
System.out.println("session已经过期");
response.sendRedirect("/plattutor3/tutor/test/login.jsp");
}else{
// 执行过滤
// 从session中获取登录者实体
Object obj= request.getSession(false).getAttribute("userInfo");
if (null == obj) {
&nb