今天我要说的是一个sessionid 错误问题 :There is no session with id[xxxxxxx]
首先我要说的是用到的框架 shiro安全框架 springmvc等
下面我把错误信息拿上来

这个错误主要发生:
我第一次访问登陆页是会出现,登陆方法:
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
logger.info("LoginPage running......");
User user = UserUtils.getUser();
// 如果已经登录,则跳转到管理首页
if(user.getId() != null){
// return "redirect:"+Global.getAdminPath();
return "redirect:/index";
}
return "/commons/index";
}
@RequestMapping(value="/login", method = RequestMethod.POST)
public String login(HttpServletRequest request, Model model){
xxxxxxxxxx
}
这两种,解释下这两种的区别,第一个login 是get 方式传输也就是说如果你第一次用url来访问登陆页那么久走这个方法。 第二个则就是post 当然就是登陆的时候要走的login 我这个错误 第一次访问会出现,logout后也会出现。很奇怪,研究了很久 发现每次出现都是走完get方式, 困扰了很久以后,我改变了思路, 不区分get 和post 因为在shiro配置文件里我们可以/login = authc,先验证后判断去向,所以代码改造后 只有他就行了
/**
* 用户登录
* @return
*/
@RequestMapping(value="/login")
public String login(HttpServletRequest request, Model model){
logger.info("User login......");
String exceptionClassName = (String)request.getAttribute("shiroLoginFailure");
String error = null;
if(UnknownAccountException.class.getName().equals(exceptionClassName)) {
error = "用户名或密码不正确";
} else if(IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
error = "用户名或密码不正确";
} else if(exceptionClassName != null) {
error = "其他错误:" + exceptionClassName;
}
model.addAttribute("ERROR_LOGIN", error);
return "/commons/index";
}
这时候有同学会问 验证成功怎么办? 那么这里还有个 利用这个方法可以控制你的去向,好了今天就说到这里吧,下次有好的分享会来的