From 1386ee0859edb2b82201aa83cd2a60140f7bf4ba Mon Sep 17 00:00:00 2001 From: pk9tv8hgp <1215904376@qq.com> Date: Mon, 24 Apr 2023 13:10:58 +0800 Subject: [PATCH] Add BaseBeforeController --- BaseBeforeController | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 BaseBeforeController 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