码迷,mamicode.com
首页 > 编程语言 > 详细

springMVC的配置文件

时间:2017-08-05 21:59:16      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:app   inf   except   multi   control   instance   property   web   注解   

<?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的配置文件

标签:app   inf   except   multi   control   instance   property   web   注解   

原文地址:http://www.cnblogs.com/Interface123/p/7291382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!