@RequestMapping({"/index", "/"})
과
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
나를 위해 일했습니다.
-------------------내 대답을 참조하십시오 : https://stackoverflow.com/a/15551678/173149 또는 그냥 :
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
<url-pattern>/index.htm</url-pattern> <<== *1*
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.htm</welcome-file> <<== *2*
</welcome-file-list>
-------------------Java 구성의 경우 WebMvcConfigurerAdapter를 확장하는 클래스에서 두 가지 메서드를 재정의 할 수 있습니다.
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("/index");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
index.html을 명시 적으로 제공하려면 아래와 같은 클래스의 메서드를 재정의하는 리소스로 전환합니다.
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/index.html").addResourceLocations("/WEB-INF/views/index.html");
}
물론 addResourceLocations
보기를 보관하기 위해 선택한 폴더를 따라야합니다.
이 샘플 보기
-------------------사용해보십시오
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
출처
https://stackoverflow.com/questions/7415084