Spring boot根路径跳转到默认首页
spring boot中可以设置默认首页,当输入域名是可以自动跳转到默认指定的网页
package cn.maxap.web;
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;
/**
* 跳转到默认首页
* @author Liuhaihua
*
*/
@Configuration
public class DefaultView extends WebMvcConfigurerAdapter{
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
super.addViewControllers(registry);
}
}
正文到此结束