@RequestMapping("/admin")
public String index(ModelMap modelMap,HttpServletRequest req,HttpSession httpSession){
String basePath = getBasePath(req);
modelMap.put("basePath",basePath);
modelMap.put("adminPath", basePath+"admin/");
modelMap.put("staticPath", basePath+"static/admin/common");
if(httpSession.getAttribute("admin") == null) {
return "redirect:/admin/login";
}
modelMap.put("admin", (Admin)httpSession.getAttribute("admin"));
return "admin/index";
}
/admin/index
/admin/info
/admin/page
/admin/list
/admin/table
/admin/contact
/admin/products
/admin/add
/admin/delete
/admin/get
现在有好多controller需要加上用户是否登录,代码如下:
if(httpSession.getAttribute("admin") == null) {
return "redirect:/admin/login";
}
难道只能一个一个加这段代码吗?
largeQ
相关分类