2
我使用的是Spring Boot,主要用于为一些静态内容提供一些基本的附加功能。用java配置在spring启动时的欢迎文件
最近我总算默认/视图映射到我的index.html通过以下方式:
@Configuration
@EnableAutoConfiguration
@EnableWebMvc
@ComponentScan
public class WebStarter extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/app/shared/**").addResourceLocations("classpath:/www/app/shared/");
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index.html");
}
public static void main(String[] args) throws Exception {
run(WebStarter.class, args);
}
}
现在我没有能够解决这个问题,我不明白为什么。我只是收到以下异常:
javax.servlet.ServletException: Could not resolve view with name 'index.html' in servlet with name 'dispatcherServlet'
也许是某种与Spring引导版本的联系,因为我最近改变它。或者有没有其他的方式来映射默认视图?