1

Spring Web アプリケーションで Twitter Bootstrap を使用しようとしています。静的コンテンツは提供されません。SOに関する多くの回答を見てきましたが、まだこれを解決できません。

mvc-dispatcher-servlet.xml

 <mvc:resources mapping="/resources/**" location="/resources/" />
 <mvc:annotation-driven />
 <context:annotation-config/>
 <context:component-scan base-package="com.indie.stock.controllers" />
 <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="250000"/>
</bean>

<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>

web.xml

 <web-app>
<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>

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-security.xml
        classpath:com/indie/stock/applicationContext.xml
    </param-value>
</context-param>

<!-- Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>
        org.springframework.web.filter.DelegatingFilterProxy
    </filter-class>
</filter>

<filter>
    <filter-name>noCacheFilter</filter-name>
    <filter-class>
        com.indie.stock.filters.NoCacheFilter
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>noCacheFilter</filter-name>
    <url-pattern>/login</url-pattern>
</filter-mapping>

私のjspsでは、この方法で静的コンテンツを参照しています

<link rel="shortcut icon" href="/resources/bootstrap-3.0.0/assets/ico/favicon.png">

ここに画像の説明を入力

私は何が欠けていますか?

編集:静的リソースにアクセスしようとすると、次のようになります

2013-09-01 23:46:37 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'mvc-dispatcher' processing GET request for [/resources/1122.jpg]
2013-09-01 23:46:37 DEBUG RequestMappingHandlerMapping:220 - Looking up handler method for path /resources/1122.jpg
2013-09-01 23:46:37 DEBUG ExceptionHandlerExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG ResponseStatusExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG DefaultHandlerExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 WARN  PageNotFound:194 - Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG DispatcherServlet:999 - Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling
2013-09-01 23:46:37 DEBUG DispatcherServlet:966 - Successfully completed request
2013-09-01 23:46:37 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'mvc-dispatcher' processing GET request for [/favicon.ico]
2013-09-01 23:46:37 DEBUG RequestMappingHandlerMapping:220 - Looking up handler method for path /favicon.ico
2013-09-01 23:46:37 DEBUG ExceptionHandlerExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG ResponseStatusExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG DefaultHandlerExceptionResolver:132 - Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2013-09-01 23:46:37 WARN  PageNotFound:194 - Request method 'GET' not supported
2013-09-01 23:46:37 DEBUG DispatcherServlet:999 - Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling
2013-09-01 23:46:37 DEBUG DispatcherServlet:966 - Successfully completed request
4

4 に答える 4

0

サーブレットベースの Web アプリケーションは何らかのコンテキストにデプロイされるため、すべての URL にコンテキスト名を追加する必要があります。

ROOT.warたとえば、Tomcat では、war が呼び出されない限り (または、context.xml を変更して自分で名前を構成しない限り) 、デフォルトでコンテキストは war ファイル名と同じです。存在する場合はROOT.war、ルート コンテキストにデプロイされます。

その問題を除外するには、使用してみてください

<link rel="shortcut icon"  href="<c:url value='/resources/bootstrap-3.0.0/assets/ico/favicon.png' />" />

それが何であれ、自動的にコンテキスト名を URL の先頭に追加します。

于 2013-09-01T18:05:38.800 に答える