diff --git a/BaseController b/BaseController new file mode 100644 index 0000000..1580024 --- /dev/null +++ b/BaseController @@ -0,0 +1,21 @@ +package com.controller.admin; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; + +import com.exception.AdminLoginNoException; +@Controller +public class BaseController { + /** + * 登录权限控制,处理方法执行前执行该方法 + * @throws AdminLoginNoException + */ + @ModelAttribute + public void isLogin(HttpSession session, HttpServletRequest request) throws AdminLoginNoException { + if(session.getAttribute("auser") == null){ + throw new AdminLoginNoException("没有登录"); + } + } +} \ No newline at end of file