Announcement Announcement Module
Collapse
No announcement yet.
Problem serving JS resources Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    And why should the mvc:resources tag influence how the urls are created?! How are you creating the urls in your JSP.

    Comment


    • #3
      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...

      Comment

      Working...
      X