1. 程式人生 > >springMVC的配置文件

springMVC的配置文件

ram enc ffi one upload and mapping adsi 所有

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

<!-- 通過bean的name,完成url映射 -->
<!-- <bean name="/springMVC.html" class="cn.bdqn.controller.HelloController"/> -->
<!--使用annotation方式,完成映射-->
<!--讓spring掃描包下的所有的類,讓標註spring註解的類生效 -->
<context:component-scan base-package="cn.bdqn.controller"></context:component-scan>
<!-- 開啟註解 -->
<mvc:annotation-driven/>


<!-- 視圖解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- 全局異常 -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="cn.bdqn.bean.UserException">error</prop>
</props>
</property>
</bean>
<!--配置靜態文件訪問springMVC中無法訪問靜態文件,需要映射成URL路徑進行訪問 -->

<mvc:resources location="/statics/" mapping="/statics/**"/>
<!--配置文件上傳 MultiPartResovler -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="1000000"/>
</bean>
</beans>

springMVC的配置文件