spring-web.xml 3.85 KB
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc" 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:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop.xsd
		http://www.springframework.org/schema/mvc
		http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <mvc:resources mapping="/assets/**" location="/"/>

    <mvc:annotation-driven>

        <mvc:argument-resolvers>
            <bean class="com.diligrp.website.util.web.resolver.BeanArgumentResolver"/>
        </mvc:argument-resolvers>

        <mvc:message-converters register-defaults="true">
            <!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8"/>
            </bean>
            <!-- 将Jackson2HttpMessageConverter的默认格式化输出设为true -->
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="prettyPrint" value="true"/>
            </bean>
        </mvc:message-converters>

    </mvc:annotation-driven>
    <!-- 视图解析器配置 -->
    <bean id="velocityConfigurer"
          class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath" value="/WEB-INF/views/"/>
        <property name="configLocation" value="classpath:velocity.properties"/>
    </bean>
    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="suffix" value=".vm"/>
        <property name="contentType" value="text/html;charset=UTF-8"/>
    </bean>

    <!-- 文件上传 -->
    <bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>

    <bean id="webUtils" class="com.b2c.myapp.utils.WebUtils">
        <property name="assetsPath" value="${project.default.assets.path}" />
        <property name="commonAssetsPath" value="${project.default.assets.common.path}" />
        <property name="localPath" value="${project.localPath}" />
    </bean>

    <bean id="dateUtils" class="com.diligrp.website.util.format.DateFormatUtils"/>

    <bean id="moneyUtils" class="com.diligrp.website.util.format.MoneyUtils"/>


    <bean id="velocityDefaultLayout" class="java.lang.String">
         <constructor-arg value="layout/default"/>
    </bean>

    <bean id="velocityTools" class="java.util.HashMap">
        <constructor-arg>
            <map>
                <entry key="webUtils" value-ref="webUtils"/>
                <entry key="dateUtils" value-ref="dateUtils"/>
                <entry key="moneyUtils" value-ref="moneyUtils"/>
            </map>
        </constructor-arg>
    </bean>


    <!--<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">-->
        <!--<property name="exceptionMappings">-->
            <!--<props>-->
                <!--<prop key="java.lang.Throwable">redirect:/500.html</prop>-->
            <!--</props>-->
        <!--</property>-->
    <!--</bean>-->
</beans>