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

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.

主站蜘蛛池模板: 中方县| 玛纳斯县| 奎屯市| 台前县| 沅陵县| 德州市| 洛扎县| 澎湖县| 自治县| 黑水县| 象山县| 大港区| 兴安县| 南昌市| 呼玛县| 收藏| 永川市| 临漳县| 乐昌市| 尼勒克县| 综艺| 应城市| 民勤县| 永安市| 策勒县| 依安县| 方城县| 曲松县| 清涧县| 呼伦贝尔市| 九寨沟县| 浦江县| 衡阳县| 曲靖市| 会泽县| 张北县| 澄城县| 会宁县| 临泽县| 丘北县| 伽师县|