項目(不可見)
https://www.aliyundrive.com/drive/folder/610003bc195cb0f2eb214891a2d78f90c2471e4b
文件 > soft > SoftWorkspace > IdeaWorkspace > springboot2-09-jpa(FilterAndInterceptor).rar
Postman請求
日誌效果
2021-07-27 20:42:47.580 INFO 36568 --- [nio-9090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/jpa] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2021-07-27 20:42:47.580 INFO 36568 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2021-07-27 20:42:47.584 INFO 36568 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms 2021-07-27 20:42:47.589 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : 進入 2021-07-27 20:42:47.593 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數進入 2021-07-27 20:42:47.594 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數進行中 request.hashCode() 1377797832 已執行 request.getInputStream() 方法 2021-07-27 20:42:47.632 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數跳出 2021-07-27 20:42:47.633 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.634 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : 111111 requestWrapper.getBody() {"a":"b"} 2021-07-27 20:42:47.634 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : 111111 request.hashCode() 1377797832 , wrap.hashCode() 93171850 2021-07-27 20:42:47.634 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.636 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : 進入 2021-07-27 20:42:47.636 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數進入 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數進行中 request.hashCode() 93171850 已執行 request.getInputStream() 方法 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] com.bobo.code.aop.MyRequestWrapper : 構造函數跳出 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : 222222 requestWrapper.getBody() {"a":"b"} 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : 222222 request.hashCode() 93171850 , wrap.hashCode() 808333661 2021-07-27 20:42:47.637 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.642 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : 進入 2021-07-27 20:42:47.642 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : header's sign value is xxxyyyzzz 2021-07-27 20:42:47.642 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : request 808333661 調用 request.getInputStream() 1次 2021-07-27 20:42:47.642 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : request 808333661 調用 request.getInputStream() 2次,因爲是MyRequestWrapper所以多次調用不拋EOF異常 2021-07-27 20:42:47.642 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : request 808333661 調用 request.getInputStream() 3次,因爲是MyRequestWrapper所以多次調用不拋EOF異常 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : 驗籤成功 , 返回boolean標誌true 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor1 : 跳出 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : 進入 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : header's sign value is xxxyyyzzz 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : request 808333661 調用 request.getInputStream() 1次 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : request 808333661 調用 request.getInputStream() 2次,因爲是MyRequestWrapper所以多次調用不拋EOF異常 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : request 808333661 調用 request.getInputStream() 3次,因爲是MyRequestWrapper所以多次調用不拋EOF異常 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : ---------------------------------------------------------------------- 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : 驗籤成功 , 返回boolean標誌true 2021-07-27 20:42:47.643 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.i.AuthorizationInterceptor2 : 跳出 2021-07-27 20:42:47.693 INFO 36568 --- [nio-9090-exec-1] c.b.c.w.controller.web.PersonController : 進入 2021-07-27 20:42:47.713 INFO 36568 --- [nio-9090-exec-1] c.b.c.w.controller.web.PersonController : saveOnePerson {"a":"b"} 2021-07-27 20:42:47.713 INFO 36568 --- [nio-9090-exec-1] c.b.c.w.controller.web.PersonController : 444444 request.hashCode() 808333661 , 無 wrap 2021-07-27 20:42:47.714 INFO 36568 --- [nio-9090-exec-1] c.b.c.w.controller.web.PersonController : request.hashCode() 808333661 已執行 request.getInputStream() 方法 2021-07-27 20:42:47.715 INFO 36568 --- [nio-9090-exec-1] c.b.c.w.controller.web.PersonController : 跳出 data is {"a":"b"} 2021-07-27 20:42:47.923 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter2 : 跳出 2021-07-27 20:42:47.923 INFO 36568 --- [nio-9090-exec-1] c.b.c.a.f.HttpServletRequestFilter1 : 跳出
結論
Filter執行完後會回來, 但是Interceptor和Controller都是一次性的
我的圖片在線編輯地址: https://www.processon.com/diagraming/610004b7e0b34d496234e157