package com.work.common.utils; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; import com.work.pojo.SystemUpset; import com.work.pojo.User; import com.work.service.SystemUpsetService; public class LoginInterceptor implements HandlerInterceptor { @Autowired private SystemUpsetService systemUpsetService; @Override public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception { } @Override public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception { } @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //系统配置 SystemUpset systemUpset = new SystemUpset(); List<SystemUpset> systemUpsets = systemUpsetService.getSystemUpsetList(systemUpset, null, null); if(systemUpsets.size() > 0){ request.setAttribute("systemUpset", systemUpsets.get(0)); } //请求链接 String url = request.getRequestURI(); User pcUser = (User) request.getSession().getAttribute("pcUser"); User serverUser = (User) request.getSession().getAttribute("serverUser"); //对个人中心和动作请求进行拦截 if(url.contains("pc/personal") || url.contains("pc/action")){ if(pcUser != null){ return true; } else{ request.setAttribute("msg", "您还没有登录,请先登录!"); request.getRequestDispatcher("/WEB-INF/jsp/pc/login.jsp").forward(request, response); return false; } } //后台管理进行拦截 if(url.contains("server")){ if(serverUser != null){ return true; } else{ request.setAttribute("msg", "您还没有登录,请先登录!"); request.getRequestDispatcher("/WEB-INF/jsp/server/login.jsp").forward(request, response); return false; } } return true; } }

leipengshen LV8
2024年12月27日
翻斗花园胡英俊 LV2
2024年12月8日
bridge_44 LV2
2024年10月28日
穿山甲1001 LV6
2024年9月12日
TY0165 LV20
2024年6月21日
微信网友_7024879466991616 LV2
2024年6月6日
yyhrhv LV8
2024年5月31日
吞吞吐吐她 LV6
2024年4月21日
860421 LV3
2024年4月18日
zolscy LV24
2024年3月24日

周君睿
6月3日
暂无贡献等级
lwj2006
6月3日
暂无贡献等级
chengguo123
4月2日
暂无贡献等级
哪里的完整版 LV8
3月10日
暂无贡献等级
微信网友_7392432759902208
2月20日
暂无贡献等级
微信网友_7371218154688512 LV4
2月5日
mymzmymzhhuu
1月5日
暂无贡献等级
leipengshen LV8
2024年12月27日
2435058517
2024年12月2日
暂无贡献等级