1.我们在controller层添加session,添加Session,这里添加的时候使用的是 HttpSession:
controllerr层的方法:
public String testShiroAnnotation(HttpSession session) {
session.setAttribute("key", "yang123456");
shiroService.testMethod();
return "redirect:/list.jsp";
}
2.在Service层中获取Session,注意这里使用的是Shiro提供的Session: