请问,spring高手,spring mvc的命名空间的配置是不是一定要加版本号
比如:spring4.6命名空间的配置可以配为http://www.springframework.org/schema/mvc/spring-mvc.xsd,项目可以正...
比如:spring4 .6命名空间的配置可以配为http://www.springframework.org/schema/mvc/spring-mvc.xsd,项目可以正常运行,但是加入静态资源,<mvc:resources mapping="/css/**" location="/css/"/>,就不识别该标签了,必须将命名空间修改为
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd,才可以识别,根据spring文档,spring4以后的命名空间已经不再需要版本号了啊,这是为什么啊? 展开
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd,才可以识别,根据spring文档,spring4以后的命名空间已经不再需要版本号了啊,这是为什么啊? 展开
1个回答
展开全部
点击你上面的两个链接看了下,在这两个schema文件中都有resources 这个节点的定义在的。
<?xml version="1.0"?>
<xsd:element name="resources">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
<![CDATA[
Configures a handler for serving static resources such as images, js, and, css files with cache headers optimized for efficient loading in a web browser. Allows resources to be served out of any path that is reachable via Spring's Resource handling.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="cache-control" type="cache-control" minOccurs="0" maxOccurs="1"/>
<xsd:element name="resource-chain" type="resource-chain" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="mapping" use="required" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The URL mapping pattern within the current Servlet context to use for serving resources from this handler, such as "/resources/**"
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="location" use="required" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The resource location from which to serve static content, specified at a Spring Resource pattern. Each location must point to a valid directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked for a given resource in the order specified. For example, a value of "/, classpath:/META-INF/public-web-resources/" will allow resources to be served both from the web app root and from any JAR on the classpath that contains a /META-INF/public-web-resources/ directory, with resources in the web app root taking precedence.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-period" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Specifies the cache period for the resources served by this resource handler, in seconds. The default is to not send any cache headers but rather to rely on last-modified timestamps only. Set this to 0 in order to send cache headers that prevent caching, or to a positive number of seconds in order to send cache headers with the given max-age value.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:token">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Specifies the order of the HandlerMapping for the resource handler. The default order is Ordered.LOWEST_PRECEDENCE - 1.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
不知道你那边报了什么错误;
需要指定版本号应该是xml文件中定义了未制定版本好的schema文件中未定义的节点。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询