0

jQuery Mobile フロントエンドに静的リソースを提供する Spring (3.2.2) バックエンドがあります。リソースはマップ /webapp/resources/images の下にあります。このマップに既に存在するリソースは正しく返されますが、新しいリソースを追加して (ブラウザを使用して) アクセスしようとすると、404 not found が表示されます。マップから既存のリソースを削除しても、リクエストに応じてまだ見つかります。これはキャッシングの問題だと思いますか?

web.xml

<?xml version="1.0"?>
<web-app id="WebApp_ID" version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
 </context-param>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <servlet>
  <servlet-name>mvc-dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>mvc-dispatcher</servlet-name>
  <url-pattern>/</url-pattern>
 </servlet-mapping>
</web-app>

mvc-dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">


    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>mymessages</value>
            </list>
        </property>
    </bean>

    <context:component-scan base-package="com.bvb.oiga.frontend.page.controller"/>
    <context:component-scan base-package="com.bvb.oiga.dto"/>

    <mvc:annotation-driven />
    <mvc:resources mapping="/resources/**" location="/resources/, classpath:/resources/" cache-period="0"  />

    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    <property name="mediaTypes">
        <map>
        <entry key="html" value="text/html"/>
        <entry key="json" value="application/json"/>
        <entry key="form" value="application/x-www-form-urlencoded"/>
        </map>
    </property>
    <property name="viewResolvers">
        <list>
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="prefix">
                        <value>/WEB-INF/pages/</value>
                    </property>
                    <property name="suffix">
                        <value>.jsp</value>
                    </property>
            </bean>
        </list>
    </property>
    <property name="defaultViews">
        <list>
        <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
        </list>
    </property>
    </bean>
</beans>

ロギング:

.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.RequestFacade@d15c31
.DispatcherServlet - DispatcherServlet with name 'mvc-dispatcher' processing GET request for [/oiga-frontend/resources/images/new-logo-sm.png]
.DispatcherServlet - Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@30562b] in DispatcherServlet with name 'mvc-dispatcher'
.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /resources/images/new-logo-sm.png
.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/resources/images/new-logo-sm.png]
.DispatcherServlet - Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@181ddd] in DispatcherServlet with name 'mvc-dispatcher'
.handler.BeanNameUrlHandlerMapping - No handler mapping found for [/resources/images/new-logo-sm.png]
.DispatcherServlet - Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@f59bb9] in DispatcherServlet with name 'mvc-dispatcher'
.handler.SimpleUrlHandlerMapping - Matching patterns for request [/resources/images/new-logo-sm.png] are [/resources/**]
.handler.SimpleUrlHandlerMapping - URI Template variables for request [/resources/images/new-logo-sm.png] are {}
.handler.SimpleUrlHandlerMapping - Mapping [/resources/images/new-logo-sm.png] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler@1ed7b17] and 1 interceptor
.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@2c304d]
.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter@1172b04]
.DispatcherServlet - Last-Modified value for [/oiga-frontend/resources/images/new-logo-sm.png] is: -1
.resource.ResourceHttpRequestHandler - Trying relative path [images/new-logo-sm.png] against base location: ServletContext resource [/resources/]
.resource.ResourceHttpRequestHandler - Relative resource doesn't exist or isn't readable: ServletContext resource [/resources/images/new-logo-sm.png]
.resource.ResourceHttpRequestHandler - Trying relative path [images/new-logo-sm.png] against base location: class path resource [resources/]
.resource.ResourceHttpRequestHandler - Relative resource doesn't exist or isn't readable: class path resource [resources/images/new-logo-sm.png]
.resource.ResourceHttpRequestHandler - No matching resource found - returning 404
.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling
.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@d15c31
.DispatcherServlet - Successfully completed request

*更新:*

リソースを更新するたびに、Eclipse Juno SR2 で実行されている apache-tomcat-7.0.32 をリロード (停止/開始) します。また、運が悪くてもEclipseをシャットダウンして再起動しようとしました。

親 Pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.bvb.oiga</groupId>
  <artifactId>oiga</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <properties>
    <spring.version>3.2.2.RELEASE</spring.version>
    <java.version>1.7</java.version>
    <log4j.version>1.2.16</log4j.version>
    <spring.ws.version>2.0.0.RELEASE</spring.ws.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.security>3.1.3.RELEASE</spring.security>
  </properties>
  <modules>
    <module>oiga-comtrex</module>
    <module>oiga-backend-webservice</module>
    <module>oiga-dto</module>
    <module>oiga-frontend</module>
  </modules>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
  </build>
    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>${spring.ws.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.schema</groupId>
            <artifactId>XmlSchema</artifactId>
            <version>1.4.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.transaction</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>com.springsource.repository.bundles.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/release</url>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>

        <repository>
            <id>com.springsource.repository.bundles.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/external</url>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>

        <repository>
            <id>jboss-maven2-release-repository</id>
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss</url>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>

    </repositories>
</project>

そしてプロジェクトポン:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.bvb.oiga</groupId>
    <artifactId>oiga</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>oiga-frontend</artifactId>
  <packaging>war</packaging>

     <dependencies>
        <dependency>
            <groupId>com.bvb.oiga</groupId>
            <artifactId>oiga-dto</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.bvb.oiga</groupId>
            <artifactId>oiga-comtrex</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>       

    <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.7.1</version>
        </dependency>
    </dependencies>

</project>
4

2 に答える 2

0

推測させてください...アプリケーションの起動src/main/resources/にディレクトリの内容を変更していますか? を使用するため、ソース フォルダーの変更は実行中のアプリケーションには表示されません。フォルダーはクラスパスにもありません。ディレクトリで手順を繰り返すことにより、この理論をテストできます。target/classes/src/target/


これが問題の原因でない場合は、ビルド ツール (Maven?) とサーブレット コンテナー (Tomcat? Jetty? スタンドアロン? 埋め込み?) に関する情報を追加すると役立ちます。

于 2013-04-22T13:56:43.610 に答える