| | |
| | | HandlerMethod handlerMethod = (HandlerMethod) handler; |
| | | Class<?> beanType = handlerMethod.getBeanType(); |
| | | if (!beanType.isAnnotationPresent(LoginNoRequired.class) && !handlerMethod.hasMethodAnnotation(LoginNoRequired.class)) { |
| | | //获取token |
| | | Cookie[] cookies = request.getCookies(); |
| | | String token = request.getHeader(Constants.HEADER_USER_TOKEN); // 从 http 请求头中取出 token |
| | | if(StringUtils.isBlank(token)){ |
| | | for(Cookie c :cookies){ |
| | | if(StringUtils.equals(c.getName(),Constants.HEADER_USER_TOKEN)){ |
| | | token = c.getValue(); |
| | | token = request.getParameter(Constants.HEADER_USER_TOKEN); |
| | | } |
| | | if(StringUtils.isBlank(token)){ |
| | | Cookie[] cookies = request.getCookies(); |
| | | if (cookies != null) { |
| | | for(Cookie c :cookies){ |
| | | if(StringUtils.equals(c.getName(),Constants.HEADER_USER_TOKEN)){ |
| | | token = c.getValue(); |
| | | } |
| | | } |
| | | } |
| | | } |