我正在尝试将 Twitter Bootstrap 与我的 Spring Web 应用程序一起使用。不提供静态内容。我已经查看了关于 SO 的一堆答案,但仍然无法解决这个问题。
mvc-调度程序-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