首页 > 编程语言 > 详细

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

时间:2019-05-13 21:39:21      阅读:121      评论:0      收藏:0      [点我收藏+]

好像是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"); } }

 

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

原文:https://www.cnblogs.com/Guhongying/p/10859035.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!