1. 程式人生 > >Shiro(3) controller中獲取當前登入使用者資訊

Shiro(3) controller中獲取當前登入使用者資訊

//Shiro controller中獲取當前登入使用者資訊

方式一:

    @RequestMapping(value = "/competitorPageList" ) 
    public String competitorPageList(Model model, ) {

 Long currentUserId = (Long) SecurityUtils.getSubject().getSession().getAttribute("currentUserId"); 
 }

方式二:

 @RequestMapping(value = "/competitorPageList"
) public String competitorPageList(Model model,HttpServletRequest request ) { Long currentUserId = (Long) request.getSession().getAttribute("currentUserId"); }