Results 1 to 3 of 3

Thread: Problem serving JS resources

  1. #1
    Join Date
    Oct 2008
    Location
    On your screen
    Posts
    50

    Default Problem serving JS resources

    Hello everyone,

    I'm trying to use Spring JS and Spring Faces in my project, but the resources never get loaded, I get a 404 error when looking up the .js and .css files.

    My dispatcher servlet is mapped to /spring/* like the following in my web.xml:

    Code:
        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/config/dispatcher-servlet.xml</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/spring/*</url-pattern>
        </servlet-mapping>
    And, since I'm using Spring 3.1, I'm configuring the resources to be loaded like the documentation suggests:

    Code:
    <mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/web-resources/" />
    According to the docs, the full URL for the resources in my app should be along the lines of: /myapp/spring/resources/spring/Spring.js since my dispatcher servlet is mapped to /spring/*. However, I have not been able to configure the resources to point to that URL, no matter what I change in the mvc:resources location attribute, I always get a URL like: /myapp/resources/spring/Spring.js and the resources are not found (404 error).

    Is there something I am missing? Thank you in advance...

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    And why should the mvc:resources tag influence how the urls are created?! How are you creating the urls in your JSP.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Oct 2008
    Location
    On your screen
    Posts
    50

    Default

    I thought the same, because I'm using another mvc:resources that points to a disk location, and that is working fine... And when I hardtype the JS resources URL they are correctly found...

    Right now I'm using JSF (Facelets), and when I include the Spring Faces namespace the resources point to /myapp/resources/spring/Spring.js instead of going through the dispatcher servlet...

    As I said before, if I load them on my own pointing to the right address, they load fine, however the requests that try to load the resources automatically still fail and the browser keeps giving that error...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •