SpringMvc的配置文件

<?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:context="http://www.springframework.org/schema/context"
     xmlns:p="http://www.springframework.org/schema/p"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
     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-4.0.xsd">

    <!-- 启用注解功能 -->
    <context:annotation-config /> 
     <!--
     <bean id="freemarkerConfig"
           class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
         <property name="templateLoaderPath" value="/WEB-INF/ftl/" />
         <property name="freemarkerSettings">
             <props>
                 <prop key="defaultEncoding">UTF-8</prop>
                 <prop key="template_update_delay">0</prop>
                 <prop key="default_encoding">UTF-8</prop>
                 <prop key="number_format">0.##########</prop>
                 <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
                 <prop key="classic_compatible">true</prop>
                 <prop key="template_exception_handler">ignore</prop>
             </props>
         </property>
     </bean>

    <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
        p:prefix="/" p:suffix=".ftl">
        <property name="cache" value="false" />
        <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
        <property name="contentType" value="text/html;charset=UTF-8"></property>
        <property name="exposeRequestAttributes" value="true" />
        <property name="exposeSessionAttributes" value="true" />
        <property name="exposeSpringMacroHelpers" value="true" />
        <property name="requestContextAttribute" value="base"></property>
        <property name="order" value="0"></property>
    </bean>
    -->
     
    <!-- SpringMVC管理handler对象 -->
    <context:component-scan base-package="com.yue.ssm" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>       
    </context:component-scan>

    <!-- 视图解析器 -->
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <!-- 标准配置 -->
    <mvc:default-servlet-handler/>
    <!-- 支持对象与json的转换。 -->
    <mvc:annotation-driven/>

    <!-- 穿越火线 -->
    <!-- <mvc:view-controller path="" view-name=""/> -->

    <!-- 异常解析器 -->
        <bean id="simpleMappingExceptionResolver"           class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <!-- error页面通过value名称来获取异常对象
            默认值:"exception"
                  <property name="exceptionAttribute" value="e"/>
          -->       
        <property name="exceptionMappings">
            <props>
                <prop key="java.lang.Exception">error</prop>
            </props>
        </property>

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

    <!-- 国际化资源管理 -->
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="i18n"></property>
    </bean>
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"></bean>

    <!-- 拦截器 -->
    <!-- 配置LocaleChangeInterceptor拦截器 -->
    <mvc:interceptors>
        <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>            
    </mvc:interceptors>
</beans>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值