Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC Resources not mapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC Resources not mapping

    I don't have any idea why my Resources Mapping is not working. Following is my dispatcher servlet code.
    Stackoverflow link for the question http://stackoverflow.com/questions/1...s-not-mapping/


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/view/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
    
    <mvc:annotation-driven />
    <mvc:resources location="/static/" mapping="/static/**" />
    <context:component-scan base-package="in.codejava.personal.controllers" />
    </beans>
    All static/* url's is being mapped by a 404 Controller that I created instead of the static resources.

    My Web.XML

    Code:
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    
    <display-name>Personal Web Blogs</display-name>
    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <!--    <servlet-mapping> -->
    <!--        <servlet-name>default</servlet-name> -->
    <!--        <url-pattern>/static/*</url-pattern> -->
    <!--    </servlet-mapping> -->
    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    </web-app>
    If I remove the commented section in Web.XML it works properly.
Working...
X