为什么加上Interceptor之后就会出现这个问题?

JwtInterceptor:
package com.practice.springboot.config.interceptor;
import cn.hutool.core.util.StrUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.practice.springboot.entity.User;
import com.practice.springboot.exception.ServiceException;
import com.practice.springboot.result.Constants;
import com.practice.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class JwtInterceptor implements HandlerInterceptor {
@Autowired
private UserService userService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception{
String token=request.getHeader("token");
//如果不是映射方法直接通过
if(!(handler instanceof HandlerMethod)){
return true;
}
if(StrUtil.isBlank(token)){
throw new ServiceException(Constants.CODE_401,"无token,请重新登录");
}
//获取token中的userId
String userId;
try{
userId= JWT.decode(token).getAudience().get(0);
}catch(JWTDecodeException j){
throw new ServiceException(Constants.CODE_401,"token验证失败,请重新登陆");
}
//根据token中的userId查询数据库
User user=userService.getById(userId);
if(user==null){
throw new ServiceException(Constants.CODE_401,"用户不存在,请重新登陆");
}
//用户密码加签验证token
JWTVerifier jwtVerifier=JWT.require(Algorithm.HMAC256(user.getPassword())).build();
try{
jwtVerifier.verify(token);//验证token
}catch(JWTVerificationException e){
throw new ServiceException(Constants.CODE_401,"token验证失败,请重新登陆");
}
return true;
}
}
Interceptor:
```java
package com.practice.springboot.config;
import com.practice.springboot.config.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(jwtInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/user/login/");//拦截所有请求,通过判断token是否合法决定是否需要登录
}
@Bean
public JwtInterceptor jwtInterceptor() {
return new JwtInterceptor();
}
}