官术网_书友最值得收藏!

How it works...

When it comes to configuring the Spring MVC internals, it is not as simple as just defining a bunch of beans at least not always. This is due to the need to provide a more fine-tuned mapping of the MVC components to requests. To make things easier, Spring provides us with a collection of default methods in WebMvcConfigurer interface that we can extend and override the settings of that we need.

In the particular case of configuring interceptors, we are overriding the addInterceptors(InterceptorRegistry registry) method. This is a typical callback method where we are given a registry in order to register as many additional interceptors as we need. During the MVC autoconfiguration phase, Spring Boot, just like in the case of filters, detects instances of WebMvcConfigurer and sequentially calls the callback methods on all of them. It means that we can have more than one implementation of the WebMvcConfigurer class if we want to have some logical separation.

主站蜘蛛池模板: 宜州市| 丹凤县| 宣汉县| 奉节县| 衢州市| 清水河县| 财经| 巴青县| 武汉市| 津南区| 阳朔县| 昆山市| 巧家县| 四子王旗| 肃北| 延川县| 德保县| 游戏| 垦利县| 江津市| 温宿县| 南靖县| 仁寿县| 大化| 长沙县| 茂名市| 岳阳县| 卫辉市| 乌兰察布市| 田东县| 米易县| 微山县| 启东市| 安平县| 河北省| 绥阳县| 巴楚县| 冕宁县| 公安县| 尖扎县| 武汉市|