Question

I am using Eclipse with JBoss support installed, and have setup JBoss 7.1 as my server of choice.

In my Spring MVC Application i have the following structure

    main/webapp/resources/static/{css,img,js}
    main/webapp/WEB-INF/classes/messages_XX.properties
    main/webapp/WEB-INF/jsp/<name>.jsp

my dispatcher-context.xml contains the following

    <mvc:annotation-driven />
    <context:component-scan base-package="com.springmvc.test" />
    <mvc:resources mapping="/resources/**" location="/resources" />

And it doesn't work

i have tried reaching the content using different paths:

    <ip>:8080/test/resources/static/img/logo.png
    <ip>:8080/resources/static/img/logo.png
    <ip>:8080/test/static/img/logo.png

but it always returns 404, e.g.

    HTTP Status 404 - /resources/static/img/logo.png
    type Status report
    message /resources/static/img/logo.png
    description The requested resource (/resources/static/img/logo.png) is not available.
    JBoss Web/7.0.13.Final

i already looked around and have tried different options mentioned by different people, but none of it works.

what am i doing wrong here?

Was it helpful?

Solution

Fixed, surprisngly it works after recreating the context xmls from scratch again (and probobly fixing typos)

Changes:

dispatcher-servlet.xml

    <mvc:resources mapping="/resources/**" location="/resources" />
    to
    <mvc:resources mapping="/resources/**" location="/resources/" />

*.jsp Using jstl "c" instead of spring

    <c:url value="/resources/static/css/bootstrap.min.css" />
    instead of
    <spring:url value="/resources/static/css/bootstrap.min.css" />

However i think it was the first change that made it work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top