1
votes


I know that there are a lot of questions like this on the web (especially here) but nothing really helped my out. I am using spring mvc (spring version 3.1.0.RELEASE) and i want to access my static data via the URL.
My packages:
-src
--main
---resources
----public
inside public i have for example a test.xml file.
This is my web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/ApplicationContext.xml</param-value>
    </context-param>
<servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/ServletContext.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>

This is my ServletContext.xml

<!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/public/**" location="/resources/public/" />


Now when i enter this url "localhost:8080/bmark-central/resources/public/test.xml" i get a 404. I tried it without the context root "localhost:8080/resources/public/test.xml" and also did not get my test.xml (got also 404). am i mapping something wrong? am i missing something here? Thanks in advance :)

1

1 Answers

0
votes

The issue could be that the static resources should be relative to your webcontent - so they should be in this folder to be accessible - src/main/webapp/resources/public and not src/main/resources.