首先运行项目(index.jsp):
![图片说明](https://img-ask.csdn.net/upload/201803/19/1521442431_934828.png)
##后台Controller处理请求
跳到主页
下面就是登录进入主页,如进入管理员页面,并且点击退出 :
# 拦截器代码:
但是一旦退出到home页 页面就是空了........
不晓得咋的回事.....求教这个拦截器咋写
![图片说明](https://img-ask.csdn.net/upload/201803/19/1521442431_934828.png)
##后台Controller处理请求
但是一旦退出到home页 页面就是空了........
不晓得咋的回事.....求教这个拦截器咋写
@Override
public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
// TODO Auto-generated method stub
}
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
throws Exception {
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
//获取Session
HttpSession session = request.getSession();
String username = (String)session.getAttribute("username");
System.out.println(username);
if(username != null){
return true;
}
//不符合条件的,跳转到登录界面
String path=request.getContextPath()+"/front/home";
response.sendRedirect(path);
return false;
}