过滤器

@Override
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(new MyBaseInterceptor());
}

 

public class MyBaseInterceptor implements HandlerInterceptor

{
private static Logger logger = LogManager.getLogger(MyBaseInterceptor.class);

protected String platformId = Constant.PLATFORM_PORTAL;

public MyBaseInterceptor()
{
}

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception
{
}

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception
{

}

// Controller之前执行
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (StringTools.isNotEmpty(request.getParameter("pjax")))
{
request.setAttribute("pjax", "1");
}
else
{
request.setAttribute("pjax", "");
}
request.setAttribute("forceChangePwd", "");

String currentURL = request.getRequestURI();
logger.info("currentURL="+currentURL+",BaseInitParamUtil.WEB_PATH="+BaseInitParamUtil.getWEB_PATH());
if (currentURL.equals("/") || currentURL.equals(BaseInitParamUtil.getWEB_PATH()) || currentURL.equals(BaseInitParamUtil.getWEB_PATH()+"/"))
{
return true;
}
return verifyAction(request, response);
}

}

posted @ 2020-09-02 23:46  采蘑菇的小蜜蜂  阅读(324)  评论(0编辑  收藏  举报