prehandle 重复执行_为什么拦截器里 preHandler 会执行了 3 次?

@Override

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) {

String jwt = request.getHeader("auth");

String payloadKey = "apitest";

Map map = new HashMap<>(8);

HandlerMethod handlerMethod=(HandlerMethod)object;

Class type = handlerMethod.getBeanType();

if (type.isAnnotationPresent(Auth.class)) {

try {

if (jwt == null || jwt.isEmpty() || jwt.isBlank() || !Objects.equals(payloadKey, JwtUtil.parseJWT(jwt).get("info", String.class))) {

map.put("status", ErrorEnum.AUTH_FAILED.getStatus());

map.put("message", ErrorEnum.AUTH_FAILED.getMessage());

returnJson(response, map);

return false;

}

}catch (ExpiredJwtException | SignatureException | MalformedJwtException e){

map.put("status", ErrorEnum.AUTH_FAILED.getStatus());

map.put("message", ErrorEnum.AUTH_FAILED.getMessage());

returnJson(response, map);

return false;

}catch (Exception e){

e.printStackTrace();

}

}

log.info("1");

return true;

}

下面那个 log.info("1")为什么会执行了 3 次呢


版权声明:本文为weixin_39649478原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。