- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 175字
- 2021-06-24 19:24:41
Configuring custom interceptors
While servlet filters are a part of the Servlet API and have nothing to do with Spring besides being automatically added in the filter chain --Spring MVC provides us with another way of wrapping web requests: HandlerInterceptor. According to the documentation, HandlerInterceptor is just like a filter. Instead of wrapping a request in a nested chain, an interceptor gives us cutaway points at different phases, such as before the request gets handled, after the request has been processed, before the view has been rendered, and at the very end, after the request has been fully completed. It does not let us change anything about the request, but it does let us stop the execution by throwing an exception or returning false if the interceptor logic determines so.
Similar to using filters, Spring MVC comes with a number of premade HandlerInterceptors. The commonly used ones are LocaleChangeInterceptor and ThemeChangeInterceptor; but there are certainly others that provide great value. So let's add LocaleChangeInterceptor to our application in order to see how it is done.
- 數據存儲架構與技術
- 企業數字化創新引擎:企業級PaaS平臺HZERO
- ETL數據整合與處理(Kettle)
- 虛擬化與云計算
- Oracle RAC 11g實戰指南
- Libgdx Cross/platform Game Development Cookbook
- Hadoop與大數據挖掘(第2版)
- 數據庫開發實踐案例
- 跟老男孩學Linux運維:MySQL入門與提高實踐
- LabVIEW 完全自學手冊
- 大數據精準挖掘
- 達夢數據庫運維實戰
- IPython Interactive Computing and Visualization Cookbook(Second Edition)
- 區塊鏈技術應用與實踐案例
- Visual FoxPro數據庫技術基礎