jwt拦截器的注册与测试

main
topsun 2 years ago
parent 5c8601ca38
commit 34ec151277

@ -2,7 +2,9 @@ package com.taxi.apipassenger.controller;
import com.internal.dto.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@GetMapping("/test")

@ -0,0 +1,18 @@
package com.taxi.apipassenger.interceptor;
import org.springframework.beans.factory.annotation.Configurable;
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) {
// WebMvcConfigurer.super.addInterceptors(registry);
registry.addInterceptor(new JwtInterceptor())
.addPathPatterns("/**")//拦截的路径
.excludePathPatterns("/noauthTest");//不拦截的路径
}
}

@ -24,7 +24,6 @@ public class JwtInterceptor implements HandlerInterceptor {
try {
//解析token
JwtUtils.parseToken(token);
} catch (SignatureException exception) {
resultStr = "token sign error ";
resultBoolean = false;

Loading…
Cancel
Save