Federico Feder
Federico Feder

Reputation: 21

How handle resources likes images, *.css with Spring Mvc

I've a problem with handle static resources. It's my web-app WebAppRoot -resources -css -style.css -imahes -jsp -template.jsp -secure -template_secure.jsp so myLocation=resources

How can I handle resource in a central way, for example I put location in a variable and use this in tag

I tried with but I don't understand how have to use.

Upvotes: 2

Views: 1688

Answers (1)

nicholas.hauschild
nicholas.hauschild

Reputation: 42849

If you are using Spring 3.0.4 or later, you can use the < mvc:resources ...> element in your application configuration, and you will not need to create a Controller to handle static content for you.

It is as simple as specifying the location of your static content, and the path from which to access them:

<mvc:resources mapping="/resources/**" location="/public-resources/"/>

This uses the mvc namespace found http://static.springsource.org/schema/mvc/spring-mvc.xsd.

Upvotes: 1

Related Questions