- 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.
- Greenplum:從大數(shù)據(jù)戰(zhàn)略到實(shí)現(xiàn)
- Python數(shù)據(jù)分析與挖掘?qū)崙?zhàn)
- Java Data Science Cookbook
- Oracle RAC 11g實(shí)戰(zhàn)指南
- MySQL從入門到精通(第3版)
- 數(shù)據(jù)庫(kù)開發(fā)實(shí)踐案例
- 數(shù)據(jù)要素五論:信息、權(quán)屬、價(jià)值、安全、交易
- Learn Unity ML-Agents:Fundamentals of Unity Machine Learning
- 數(shù)據(jù)驅(qū)動(dòng)設(shè)計(jì):A/B測(cè)試提升用戶體驗(yàn)
- 智能數(shù)據(jù)時(shí)代:企業(yè)大數(shù)據(jù)戰(zhàn)略與實(shí)戰(zhàn)
- Python金融實(shí)戰(zhàn)
- 從0到1:JavaScript 快速上手
- 數(shù)據(jù)中心數(shù)字孿生應(yīng)用實(shí)踐
- Hadoop集群與安全
- MySQL數(shù)據(jù)庫(kù)技術(shù)與應(yīng)用