diff --git a/BaseBeforeController b/BaseBeforeController new file mode 100644 index 0000000..8a5aac3 --- /dev/null +++ b/BaseBeforeController @@ -0,0 +1,22 @@ +package com.controller.before; + +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.UserLoginNoException; +@Controller +public class BaseBeforeController { + /** + * 前台用户登录权限控制,处理方法执行前执行该方法 + * @throws UserLoginNoException + */ + @ModelAttribute + public void isLogin(HttpSession session, HttpServletRequest request) throws UserLoginNoException { + if(session.getAttribute("emailuser") == null){ + throw new UserLoginNoException("没有登录"); + } + } +} \ No newline at end of file