public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { boolean filter = false; User user = (User) request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) ; HandlerMethod handlerMethod = (HandlerMethod ) handler ; Menu menu = handlerMethod.getMethod().getAnnotation(Menu.class) ; if(user != null || (menu!=null && menu.access()) || handlerMethod.getBean() instanceof BasicErrorController){ filter = true; } if(!filter){ response.sendRedirect("/login.html?referer="+java.net.URLEncoder.encode(request.getRequestURL().toString() , "UTF-8")); } return filter ; }
@Bean @ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT) public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) { return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers); }