Use index.html as welcome page

前提是你 提交于 2019-12-24 17:27:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!