版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a919423654/article/details/87867059
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class DefaultView implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:index.jsp");
WebMvcConfigurer.super.addViewControllers(registry);
}
}
index.jsp 路径:resource/static/index.jsp
WebMvcConfigurerAdapter 已经过期,虽然可以用,但是看起来感觉很不爽。
如果使用 WebMvcConfigurationSupport 又会导致 自配配置失效