Frühling und tag mvc-Ressourcen, nicht erreichen können .css-und .js-Dateien

Meine Anwendung verwenden Frühling 3.0.4(das ist die erste version, wo tag mvc:Ressourcen funktionieren).
Das aktuelle Problem ist, dass meine app nicht erreichen kann .css-und .js-Dateien aus dem zugeordneten Ressourcen.

Struktur-test.Krieg:

/test -root
   |
   /static-resource
            |
            /css
               |
               /screen.css
            |
            /js
   |
   /WEB-INF
   |
   /index.jsp

Meine test-servlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/jee       http://www.springframework.org/schema/jee/spring-jee.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/aop       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

        <mvc:annotation-driven/>
    <mvc:resources mapping="/resources/**" location="/static-resource/"/>

    <context:annotation-config/>
    <context:component-scan base-package="org.web"/>
    <tx:annotation-driven/>

        <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/tiles-defs.xml</value>
                </list>
            </property>
        </bean>

        <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
        </bean>

 <bean id="authenticationInterceptor" class="org.util.AuthenticationInterceptor"/>

    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messages"/>
        <property name="defaultEncoding" value="UTF-8"/>
        <property name="cacheSeconds" value="-1"/>
    </bean>

    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang" />
    </bean>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="defaultLocale" value="en"/>
        <property name="cookieName" value="bovalta_language"/>
    </bean>

    <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <property name="interceptors">
        <list>
            <ref bean="authenticationInterceptor"/>
            <ref bean="localeChangeInterceptor"/>
       </list>
   </property>
    </bean>



</beans>

In den index.jsp versuche ich Zugang zu den Ressourcen auf zwei Arten mit Feder-url und mit JSTL url wie unten

<%-- With JSTL url --%>
<link media="screen"  href="<c:url value="/resources/css/screen.css"/>" type="text/css"/>
<%-- With Spring url --%>
<spring:url value="/resources" var="resourceUrl"/>
<link media="screen" rel="stylesheet" href="${resourceUrl}/css/screen.css" type="text/css" />

Wenn ich undeploy war-Datei im Tomcat, application funktionieren, ohne jede Ausnahme, aber Tomcat-server nicht finden können, meine css und js Dateien von Ressourcen.
Ich versuche zu erreichen css-Datei über url http://localhost:8080/test/resources/css/screen.css
aber Tomcat nicht gefunden. Jeder Vorschlag wird nützlich sein.

Vielen Dank im Voraus

InformationsquelleAutor Vladisav Milosavljevic | 2012-03-29

Schreibe einen Kommentar