2

My Spring project doesn't load with index.html as welcome file but if I rename it to index.jsp then it works fine. Why?

My web.xml

  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

page with index.html as welcome file

If I changes index.html to index.jsp, page seems to be loading.

page with index.jsp as welcome file

I have seen other question like this but with no correct answers. SO question

Community
  • 1
  • 1
Garry
  • 4,493
  • 3
  • 28
  • 48
  • Please dont remove the tags as I want tag experts to see this question and answer. Thanks. – Garry Jun 08 '15 at 20:07
  • Please understand that Spring is **completely irrelevant** for this. The *problem* is related to Java Web Applications only, despite if you use Spring MVC or any other web MVC framework like Struts 2, Vaadin, JSF or another. – Luiggi Mendoza Jun 08 '15 at 20:07
  • I agree with you but I would to like to reach to maximum audience. Thank you. – Garry Jun 08 '15 at 20:08
  • Then you're improperly using the tags and just making noise in proper questions of those tags. – Luiggi Mendoza Jun 08 '15 at 20:10
  • You are a better person and in better position to say on this, so I will remove the tags. But I request you to reach out to someone who can help me on this. I appreciate your inputs. Thanks. – Garry Jun 08 '15 at 20:12
  • 3
    Spring is mapped to `*.html` so it tries to deal with your request. You presumably have no mapping in Spring for dealing with this so the spring servlet returns a 404. In the second case, `*.jsp` is not mapped to Spring to the application server serves the jsp as requested. – Boris the Spider Jun 08 '15 at 20:15
  • Thank you. That makes sense. I will try playing with it to see how things work with different mapping. – Garry Jun 08 '15 at 20:21
  • You can find your answer here: http://stackoverflow.com/questions/24670327/welcome-file-not-working-with-html-file-in-spring – RAHUL ROY Oct 28 '16 at 18:50
  • You can find your answer here: http://stackoverflow.com/questions/24670327/welcome-file-not-working-with-html-file-in-spring – RAHUL ROY Oct 28 '16 at 18:50

0 Answers0