Spring 3.1 & JBoss 7.1 Serving static content
Although the static content should be served by the Webserver i will make another post for that, but during development for local testing purposes you might want to serve Static content from the Application server, Spring provides several options to achieve this, i am sharing one such option that i use most of the time.
Make sure you are using Spring version 3.04 and up, i use JBoss as my main webserver, and with version 7 it is blazing fast now with startup time well under 700 ms on my MBP.
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 tag for mapping /resources/** directory to the given locaion.
<mvc:resources mapping="/resources/**" location="/resources" />
In my JSPs i use the following jstl tag for defining the path to the static content
<c:url value="/resources/static/img/header.png" />
Note: if you are getting 404, please make sure that you havent made any typos on the resources mapping and that you are using the above mentioned approach only for serving static content first, mixing several solutions together can break the functionality.
How to fix “java.net.SocketException: Protocol family unavailable” URI Naming conventions and best practices