项目:https://github.com/orubel/spring-boot-starter-beapi
一直尝试在自动配置中配置 handlerInterceptor 一段时间,现在可用。
每次我拨打电话时,我总是在演示项目中看到相同的内容:
12:31:35.712 [http-nio-8080-exec-1] DEBUG i.b.a.f.RequestInitializationFilter - doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) : {}
12:31:35.762 [http-nio-8080-exec-1] DEBUG o.s.web.servlet.DispatcherServlet - GET "/v0.4-1/user/show/5", parameters={}
12:31:35.768 [http-nio-8080-exec-1] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to demo.application.controller.UserController#show(HttpServletRequest, HttpServletResponse)
12:31:35.784 [http-nio-8080-exec-1] DEBUG org.hibernate.SQL -
...
12:31:35.803 [http-nio-8080-exec-1] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
12:31:35.804 [http-nio-8080-exec-1] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Writing [{user=demo.application.domain.User@76aca0ae}]
12:31:35.861 [http-nio-8080-exec-1] DEBUG o.s.web.servlet.DispatcherServlet - Completed 200 OK
调用工作正常,但我需要 handlerInterceptor 来处理 FORWARD,这样一旦预处理完成,handlerInterceptor 就可以使用 preHandle/postHandle 处理所有路由
在阅读这篇文章(https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/handler-interceptors-registration.html)时,看起来好像我需要设置一个 HandlerMapping,但是当按照前面的例子中的示例时,我仍然一无所获......
这是一个错误吗?