Spring MVC mvc: resource location attribute

Guys I also have a problem loading static resources.

I think everything is set up correctly for me. But I do not understand the location attribute mvc: resources . What is this for?

if I have static resources at VAADIN / themes / theme / ... (in several subfolders, images, css, js), what should be the correct values ​​for the location and display attributes?

When I have the following settings:

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

he does not work. I believe the following part of the log is related:

17:15:02.897 [http-8080-2] DEBUG o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#6': no
 URL paths identified

I am getting HTTP 404 status , for example. http://127.0.0.1/VAADIN/themes/theme/css/style.css

+3
source share
4 answers

location - , . XSD :

, , Spring.      . , ,      . ,      "/, classpath:/META-INF/public-web-resources/" -     root JAR , /META -INF/public-web-resources/      -.

, mapping:

URL- , , "/resources/**"

So mapping , uri , location , , .

+5

, .

  • VAADIN WAR ( case location="/VAADIN/" )
  • WEB-INF/ ( location="classpath:/VAADIN/")?
+1

, - , httprequestresolver ( ) , AbstractUrlHandlerMapping handlermapping, 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>
0

. /resources/ **, Ant, , /resources, . , . , /resources, /resources . , , JavaScript / .

0

All Articles