0

I have deployed a sample spring java application to weblogic server (11g, 10.3.6). I have index.html at the root and I set that as the welcome-file in web.xml. But when I try to access the application, I am getting 'Error 404 -- Not Found'. Also, I noticed same issue with js and css files.

index.jsp works fine at the same location.

Here is my web.xml.

<display-name>hello</display-name>

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

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
vmrao
  • 87
  • 3
  • 10

1 Answers1

0

The reason for this is the root level mapping(/) for your Spring DispatcherServlet. All the requests are forward to Spring servlet:

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

I workaround this situation by using *.do for my Spring controllers and update the servlet mapping as mentioned here:

<servlet-mapping>
    <servlet-name>appServlet/servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

But this will require you to update the 'calls to your Spring controller' with a .do at the end of the URLs.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • @vmrao Please accept the answer by clicking on the tick mark left to my answer. Accepting an answer helps other users facing the same problem. – Juned Ahsan Jun 06 '14 at 02:05
  • I needed RESTful urls and so I ended up adding to applicationContext.xml which will allow the dispatcher servlet to be mapped to '/' and static resources served by the containers default servlet. – vmrao Jun 07 '14 at 01:24