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

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.

主站蜘蛛池模板: 大渡口区| 卢湾区| 毕节市| 肥西县| 阿坝县| 琼中| 崇义县| 大关县| 柳林县| 嘉善县| 孟津县| 金沙县| 延川县| 巴马| 延长县| 崇左市| 中山市| 丹巴县| 平泉县| 宜黄县| 罗平县| 改则县| 山丹县| 弥勒县| 花垣县| 巩义市| 兴安盟| 壶关县| 黄平县| 福清市| 多伦县| 贵溪市| 哈巴河县| 大田县| 元谋县| 金门县| 思南县| 特克斯县| 临颍县| 化德县| 霍林郭勒市|