spring-mvc - Spring MVC 4 中的资源版本控制
问题描述
任何人都可以帮助我在我的 Web 应用程序中实现资源版本控制吗?我的 dispatcher-servlet.xml 是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<!-- Declare a view resolver -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp" p:order="1" />
<context:annotation-config />
<context:component-scan base-package="com.safecare" />
<mvc:annotation-driven />
<mvc:interceptors>
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0" />
<property name="useExpiresHeader" value="false" />
<property name="useCacheControlHeader" value="true" />
<property name="useCacheControlNoStore" value="true" />
</bean>
</mvc:interceptors>
<mvc:annotation-driven />
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="Messages" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!--<prop key="hibernate.hbm2ddl.auto">update</prop>-->
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="hibernate.c3p0.min_siz">5</prop>
<prop key="hibernate.c3p0.max_size">50</prop>
<prop key="hibernate.c3p0.timeout">3000</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
<prop key="hibernate.c3p0.idle_test_period">3000</prop>-->
</props>
</property>
<property name="packagesToScan" value="com.safecare"></property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver" p:url="jdbc:mysql://localhost:8080/cortex_mcss_test1"
p:username="root" p:password="mysql" />
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean class="org.springframework.web.servlet.view.XmlViewResolver"
p:location="/WEB-INF/JasperReport-View.xml" p:order="0" />
</beans>
我确实在上面的 xml 中添加了下面的代码,它会产生一个错误
列号:18;cvc-complex-type.2.1:元素 'mvc:resources' 必须没有字符或元素信息项 [children],因为该类型的内容类型为空。
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
<mvc:cache-control max-age="3600" s-maxage="1800" cache-public="true"/>
<mvc:resource-chain resource-cache="false" auto-registration="false">
<mvc:resolvers>
<mvc:version-resolver>
<mvc:fixed-version-strategy version="abc" patterns="/**/*.js"/>
<mvc:version-strategy patterns="/**">
<bean class="org.springframework.web.servlet.resource.ContentVersionStrategy" />
</mvc:version-strategy>
</mvc:version-resolver>
<ref bean="encodedResourceResolver"/>
<bean class="org.springframework.web.servlet.resource.PathResourceResolver"/>
</mvc:resolvers>
<mvc:transformers>
<bean class="org.springframework.web.servlet.resource.CachingResourceTransformer">
<constructor-arg name="cache" ref="resourceCache" />
</bean>
<bean class="org.springframework.web.servlet.resource.AppCacheManifestTransformer"/>
</mvc:transformers>
</mvc:resource-chain>
任何人都知道上述任何适当的文件
解决方案
添加自结束标记。
改变
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
至
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/" />
推荐阅读
- linux - Windows Host Docker + WSL2 - 如何将 Windows 目录挂载到 Linux 容器
- java - 配置 Logback 以从 JBoss 检索变量
- spring-boot - 将 Spring Data JPASpecificationExecutor / QueryByDsl 与 Hibernate Full Text Search 6.0 混合
- .net-core - 使用身份服务器 4 发起付款
- css - 让 Div 在 Div 内对齐以显示圆角
- ajax - Wordpress ajax 不传递文本变量
- git - TeamCity 非阻塞 BuildType
- macos - 在 Mac 上构建 libvault 时未定义的符号
- arrays - C中2个向量的点积程序
- html - 蒙特塞拉特字体样式不起作用,为什么?