首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring 4中的资源版本控制

Spring 4中的资源版本控制
EN

Stack Overflow用户
提问于 2018-07-19 12:23:07
回答 1查看 258关注 0票数 0

有谁能帮助我在我的调度器-servlet.xml的web应用程序中实现资源版本控制吗?

代码语言:javascript
复制
    <?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中添加了下面的代码,它会创建一个错误

columnNumber: 18;cvc-复合类型.2.1:元素'mvc:resources‘必须没有字符或元素信息项子项,因为类型的内容类型是空的。

代码语言:javascript
复制
<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>

任何人都知道上述任何适当的文件。

EN

回答 1

Stack Overflow用户

发布于 2018-07-19 16:42:35

添加自结束标记。

变化

代码语言:javascript
复制
 <mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">

代码语言:javascript
复制
 <mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51422607

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档