springboot默认的欢迎页面设置
1.新建MVCConfiguration类,代码如下:
-
package com.example.demohebirnate.config;
-
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;
-
-
-
public class MVCConfiguration extends WebMvcConfigurerAdapter {
-
-
public void addViewControllers(ViewControllerRegistry registry) {
-
-
registry.addViewController(“/”).setViewName(“forward:/login.html”);
-
-
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
-
-
super.addViewControllers(registry);
-
-
}
-
}
2.新建login.html,目录为:resources/static 这里默认是static目录下,原因不详
3.访问地址:http://localhost:8080/,如图:
转载请注明:SuperIT » springboot默认的控制器和欢迎页面设置