Tomcat does not serve the static content when explicit servlet mapping define in Application web.xml

Solution Unverified - Updated -

Issue

  • We are observing HTTP 404 error while accessing the static content with servlet mapping define in Application web.xml as follows.
  • The servlet mapping for static content is not working when org.springframework.web.servlet.DispatcherServlet map to /* url-pattern as follows in application web.xml.
<servlet>
        <servlet-name>mvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    ...
    <servlet-mapping>
        <servlet-name>mvc</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/css/*</url-pattern>
    <url-pattern>/img/*</url-pattern>
    <url-pattern>/js/*</url-pattern>
    <url-pattern>/favicon.ico</url-pattern>
</servlet-mapping>

Environment

  • Red Hat Enterprise Linux (RHEL)
    • 6.5
  • Tomcat 6.0.24

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content