为什么我的拦截器在控制器之后调用
我的受体
@Slf4j
@Component
public class LoggingInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
System.out.println("Call Interceptor preHandle method");
return true;
}
}
<mvc:interceptor>
<mvc:mapping path="/*" />
<mvc:exclude-mapping path="/index*" />
<bean class="my.corp.LoggingInterceptor" />
</mvc:interceptor>
这是我的控制人:
@RestController
@RequestMapping("/api")
public class TestApiController {
@PostMapping("/test")
public TestObject create(
@RequestBody @Valid Student request) {
System.out.println("Call controller method")
return "";
}
}
但是当我向/api/test
发送请求时。
日志为:
Call controller method
Call Interceptor preHandle method
我希望preHandle
应该在Controller之前被调用,但是这里似乎出现了问题
答案 0 :(得分:0)
问题是这个 路径应为双星“ / **”