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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.