<?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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<!-- SpringMVC配置 -->
<!-- 配置扫描注解 -->
<context:component-scan base-package="cn.itcast.ssm.controller"></context:component-scan>
<!-- 配置更新处理器 -->
<mvc:annotation-driven/>
<!-- 异常处理器 -->
<bean id="handlerExceptionResolver" class="cn.itcast.ssm.exception.CustomExceptionResolver"/>
<!-- 加载注解驱动 -->
<!-- <mvc:annotation-driven conversion-service="conversionService"/>
转换器配置:用户String转换成Date
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<set>
<bean class="cn.itcast.ssm.converter.DateConverter"/>
</set>
</property>
</bean> -->
<!-- 配置视图解析器:用于方便跳转页面 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp" ></property>
</bean>
<!-- 配置一个文件解析器:用于上传文件 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置上传文件的最大尺寸为5MB -->
<property name="maxUploadSize">
<value>5242880</value>
</property>
</bean>
</beans>
SpringMVC.xml的常用配置
最新推荐文章于 2023-05-10 12:16:39 发布