Spring boot之默认首页(欢迎页)的设置

package com.winter.config.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 系统默认界面设置
 *
 * @auther hzy
 * @data 2018/4/28 9:59
 * @QQ 291471000
 */
@Configuration
public class DefaultView extends WebMvcConfigurerAdapter {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
    // login页面在 templates 文件夹下
        registry.addViewController("/").setViewName("login");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addViewControllers(registry);
    }
}
上述写法其实对等于
@RequestMapping("/")
public String view(){
    return "login";
}
 

猜你喜欢

转载自blog.csdn.net/u011429743/article/details/80117280