Springboot 实现WebMvcConfigurer接口来拓展SpringMvc的功能


好像是Spring Boot 2.0.4.RELEASEWebMvcConfigurerAdapter已过时,所以想通过继承WebMvcConfigurerAdapter来拓展SpringMvc的功能时会有一条删除线。

因此,通过实现WebMvcConfigurer接口来拓展SpringMvc的功能()

package com.example.springboot.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration public class MyMvcConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) {
    ////浏览器发送 /nihao 请求来到 success registry.addViewController(
"/nihao").setViewName("success"); } }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM