春天mvc:资源标签
问题描述:
我试图通过使用标签来获取静态资源放入我的web应用程序,但它不起作用。 我的beans.xml春天mvc:资源标签
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
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">
<context:component-scan base-package="controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
我的JSP文件
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<spring:url value="/resources/style.css" var="styleCss" />
<link rel="stylesheet" href='<c:url value="/resources/style.css"/>' />
我的文件结构:
我已经尝试了很多方法,但他们都没有按没有工作。
请帮帮我。 非常感谢
答
试试这个:
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" />
,因为你已经保持了WEB-INF内的资源,你需要包括在资源路径。