问题
I have a simple java application. I want to set index.html as my welcome page.
I tried it but its not working. Although index.jsp is working. Is it possible to use index.html?
<display-name>sample</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>sample</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sample</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
回答1:
Maybe it is because of the servlet mapping you are doing.
You should change <url-pattern>*.html</url-pattern>
to something different so that there is no diffusion.
回答2:
Update your web.xml
<welcome-file-list>
<welcome-file>webContent/index.html</welcome-file>
</welcome-file-list>
You are getting 404 - Page not found because you cannot access files under WEB-INF folder directly
来源:https://stackoverflow.com/questions/25752171/use-index-html-as-welcome-page