Guys I have also problem with loading static resources.
I think I have everything properly set up. But I don\'t understand location attribute of
My Guess is that you're not referencing the location correctly.
location="/VAADIN/"
is
correct)location="classpath:/VAADIN/"
) ?sets up a handler for serving static content. The mapping attribute is set to /resources/**, which includes an Ant-style wildcard to indicate that the path must begin with /resources, but may include any subpath thereof. The location attribute indicates the location of the files to be served. As configured here, any requests whose paths begin with /resources will be automatically served from the /resources folder at the root of the application. Therefore, all of our images, stylesheets, JavaScript, and other static content needs to be kept in the application’s /resources folder.
Maybe you have configured some handlermapping that kicks in before the resourcehttprequestresolver (or whatever it's called) Check that you don't have an AbstractUrlHandlerMapping or any other handlermapping that stops the mapping chain with an order property. Or configure the resource resolver with an order: <mvc:resources ... order="1" />
<!-- Maps all other request URLs to views -->
<bean id="viewMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="defaultHandler">
<!-- Selects view names to render based on the request URI: e.g. the "/Home" URL would map to the view named "Home" -->
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
</property>
<!-- This will prevent the mvc:resources to handle requests. Unless, of course, you specify an order in the mvc:resources order attribute
<property name="order" value="3" / Removing this will place this just after The ResourceHttpRequestHandler-->
</bean>
location
is the location to the folder where the resources are placed. The XSD docs write:
The resource location from which to serve static content, specified at a Spring Resource pattern. Each location must point to a valid directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked for a given resource in the order specified. For example, a value of "/, classpath:/META-INF/public-web-resources/" will allow resources to be served both from the web app root and from any JAR on the classpath that contains a /META-INF/public-web-resources/ directory, with resources in the web app root taking precedence.
On the other hand, the mapping
attribute is:
The URL mapping pattern, within the current Servlet context, to use for serving resources from this handler, such as "/resources/**"
So mapping
specifies under what uri will resources be accessible on the web, while location
specifies where are these resources located on the disk.