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: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>

时间: 2024-08-06 20:01:02

springMVC的配置文件的相关文章

SpringMVC Service配置文件讲解

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

SpringMVC深度探险(四) —— SpringMVC核心配置文件详解

本文是专栏文章(SpringMVC深度探险)系列的文章之一,博客地址为:http://downpour.iteye.com/blog/1389285. 在上一篇文章中,我们从DispatcherServlet谈起,最终为读者详细分析了SpringMVC的初始化主线的全部过程.整个初始化主线的研究,其实始终围绕着DispatcherServlet.WebApplicationContext和组件这三大元素之间的关系展开. 在文章写完之后,也陆续收到了一些反馈,其中比较集中的问题,是有关WebApp

SpringMVC学习(三)——SpringMVC的配置文件

读者阅读过SpringMVC学习(一)——SpringMVC介绍与入门这篇文章后,想必都会写写SpringMVC的入门小程序,在这个小程序中,SpringMVC的核心配置文件——springmvc.xml为: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=&qu

[jbdj]SpringMVC框架(2)加载自定义目录下的springmvc.xml配置文件

自己定义文件目录,文件名称无疑是件快乐的事情! 如果springmvc.xml配置文件放在src目录下,web.xml代码如下: <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/200

springMVC项目配置文件

一.springMVC项目配置文件 1.web.xml文件全局配置 <servlet> <servlet-name> dispatcher </servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet  </servlet-class> </servlet> <servlet-mapping> <servlet-na

SpringMVC开发配置文件详解

一.Spring MVC环境搭建:(Spring 2.5.6 + Hibernate 3.2.0) 1. jar包引入 Spring 2.5.6:spring.jar.spring-webmvc.jar.commons-logging.jar.cglib-nodep-2.1_3.jar Hibernate 3.6.8:hibernate3.jar.hibernate-jpa-2.0-api-1.0.1.Final.jar.antlr-2.7.6.jar.commons-collections-3

springMVC之配置文件实现

第一:要了解springMVC的运行原理 第二:我们为什么要使用springmvc? 那就是为了替代我们用servlet来处理和响应请求,虽然它的底层依然是servlet,但是利用框架不仅能够减少我们的代码量,还能让我们更加专注于业务逻辑. 第二:响应的方式:一种是配置文件,另一种是注解 这里先讲解配置文件方式的形式:如果我们自己定义了controller类,那么与直接使用框架中的是不同的 在这里我们先自己创建一个controller类 controller类代码: 1 /** 2 * 3 */

Spring+SpringMVC重复加载配置文件问题

sping+springmvc的框架中,IOC容器的加载过程 http://my.oschina.net/xianggao/blog/596476 基本上是先加载ContextLoaderListener,然后生成一个ioc容器. 然后再实例化DispatchServlet时候在加载对应的配置文件,再次生成Controller相关的IOC容器 关于上面两个容器关系: ContextLoaderListener中创建ApplicationContext主要用于整个Web应用程序需要共享的一些组件,

spring+springmvc+mybatis配置文件

最近在学习SSM,自己上手了一个crm项目,这两天对底层配置文件做了个总结. sqlmapconfig.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd&qu