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

<!-- 自动扫描包,可以写多个 -->
<context:component-scan base-package="com.xxx,com.xxx.session,com.xxx.xxx" ></context:component-scan>

<!-- 多视图处理器 -->
<bean class="com.xxx.core.web.MixedViewResolver">
<property name="resolvers">
<map>
<entry key="jsp">
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
</bean>
</entry>
<entry key="ftl">
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true"/>
<property name="contentType" value="text/html;charset=UTF-8"></property>
<!-- 宏命令的支持 -->
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
<property name="requestContextAttribute" value="rc"></property>
</bean>
</entry>
</map>
</property>
</bean>

<!-- freemarker config -->
<bean id="freeMarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/ftl/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay">5</prop>
<prop key="default_encoding">UTF-8</prop>
<prop key="locale">zh_CN</prop>
</props>
</property>
</bean>

<!-- 日志拦截器-->
<bean id="logNDCInteceptor" class="com.xxx.core.web.LogNDCInteceptor"/>

<!-- 权限拦截器-->
<bean id="myPermissionsInteceptor" class="com.xxx.userplatform.mvc.MyPermissionsInteceptor"></bean>

<!-- RequestHelper拦截器-->
<bean id="myRequestHelperInteceptor" class="com.xxx.core.web.MyRequestHelperInteceptor"></bean>

<!-- 用户信息拦截器-->
<bean id="myUserInfoInteceptor" class="com.xxx.userplatform.mvc.MyUserInfoInteceptor"></bean>

<!-- 注解请求映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="logNDCInteceptor"/> <!-- 日志拦截器 -->
<ref bean="myRequestHelperInteceptor"/> <!-- RequestHelper拦截器-->
<ref bean="myPermissionsInteceptor"/> <!-- 权限拦截器-->
<ref bean="myUserInfoInteceptor"/> <!-- 用户信息拦截器-->
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="byteArray_hmc" />
<ref bean="string_hmc" />
<ref bean="resource_hmc" />
<ref bean="source_hmc" />
<ref bean="xmlAwareForm_hmc" />
<ref bean="jaxb2RootElement_hmc" />
<ref bean="jackson_hmc" />
</list>
</property>
</bean>
<bean id="byteArray_hmc" class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /><!-- 处理.. -->
<bean id="string_hmc" class="org.springframework.http.converter.StringHttpMessageConverter" /><!-- 处理.. -->
<bean id="resource_hmc" class="org.springframework.http.converter.ResourceHttpMessageConverter" /><!-- 处理.. -->
<bean id="source_hmc" class="org.springframework.http.converter.xml.SourceHttpMessageConverter" /><!-- 处理.. -->
<bean id="xmlAwareForm_hmc" class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" /><!-- 处理.. -->
<bean id="jaxb2RootElement_hmc" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" /><!-- 处理.. -->
<bean id="jackson_hmc" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /><!-- 处理json-->

<!-- 总错误处理-->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">

<property name="exceptionMappings">
<props>
<!-- 上传文件大于最大尺寸后转向出错页面 -->
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">
redirect:/uploadError.jsp
</prop>
</props>
</property>
<property name="defaultErrorView">
<value>forward:/error.jsp</value>
</property>
<property name="defaultStatusCode">
<value>200</value>
</property>
<property name="warnLogCategory">
<value>org.springframework.web.servlet.handler.SimpleMappingExceptionResolver</value>
</property>

</bean>

<!-- 允许对静态资源文件的访问 -->
<mvc:default-servlet-handler/>

<!-- 数据源 ,DBCP连接池-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@192.168.3.141:1521:xxx"/>
<property name="username" value="xxxdb"/>
<property name="password" value="xxxdb"/>
<property name="initialSize" value="2"/>
<property name="maxActive" value="10"/>
<property name="maxIdle" value="10"/>
<property name="maxWait" value="1000"/>
<property name="poolPreparedStatements" value="true"/>
</bean>

<!-- JNDI数据源
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc/xxx</value>
</property>
</bean>
-->

<!-- JDBC模板 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 用注解来实现事务管理 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

<!-- 用于持有ApplicationContext,可以使用SpringContextHolder.getBean('xxxx')的静态方法得到spring bean对象 -->
<bean class="com.xxxxx.SpringContextHolder" lazy-init="false" />

</beans>

Spring MVC 配置文件的更多相关文章

  1. Spring MVC 配置文件dispatcher-servlet.xml 文件详解

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. Spring MVC 配置文件dispatcher-servlet.xml 文件详解(转自 学无止境-yj)

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  3. Spring MVC配置文件的三个常用配置详解

    转自:http://www.cnblogs.com/benwu/articles/5162614.html Spring MVC项目中通常会有二个配置文件,sprng-servlet.xml和appl ...

  4. spring mvc 配置文件拦截器过滤url

    最近在用spring mvc拦截器,sprin 版本号4.0.6.RELEASE, <mvc:interceptor> <mvc:mapping path="/admin/ ...

  5. spring配置文件和spring mvc配置文件的区别

    Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...

  6. Spring MVC配置文件

    都说开发Spring Web程序的配置文件很繁琐,所以就写了一篇配置博客, 首先是pom.xml文件 <project xmlns="http://maven.apache.org/P ...

  7. spring mvc 配置文件信息记录

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  8. spring mvc配置文件dispatcher-servlet.xml详解

    Spring的配置文档<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="ht ...

  9. Spring MVC配置文件解释

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

随机推荐

  1. Tomcat 8.5 架构分析

    官方文档:Apache Tomcat 8 Architecture 以下分析的是 Version 8.5. Tomcat 组件关系图 根据 Architecture Overview 绘制: Serv ...

  2. Lock分析

      Lock接口是锁的实现,用来控制多个线程访问共享资源的方式,是在java 1.5的时候引入的,在此之前,只能通过synchronized的方式来取得对象的锁. synchronized中的锁是隐式 ...

  3. 1094 The Largest Generation

    题意:略. 思路:层序遍历:在结点中增加一个数据域表示结点所在的层次. 代码: #include <cstdio> #include <queue> #include < ...

  4. KEGG Pathway Anonatation

    转载于 Original 2017-06-20 liuhui 生信百科 KEGG 数据库中,把功能相似的蛋白质归为同一组,然后标上 KO 号.通过相似性比对,可以为未知功能的蛋白序列注释上 KO 号. ...

  5. mysql 里的 ibdata1 文件不断的增长

    我们在 Percona 支持栏目经常收到关于 MySQL 的 ibdata1 文件的这个问题.当监控服务器发送一个关于 MySQL 服务器存储的报警时,恐慌就开始了 —— 就是说磁盘快要满了.一番调查 ...

  6. Spring实战之切面编程

    如果要重用通用功能的话,最常见的面向对象技术是继承(inheritance)或委托(delegation).但是,如果在整个应用中都使用相同的基类,继承往往会导致一个脆弱的对象体系:而使用委托可能需要 ...

  7. 教你看懂Code128条形码

    首     页 条码控件 条码技术 条码新闻 合作伙伴 联系我们 常见问题 电话:010-84827961 当前位置:条形码控件网 > 条形码控件技术文章 > >正文   教你看懂C ...

  8. leetcode707

    数据结构的题,从网上找到的实现方式,先记录下来. class MyLinkedList { public: /** Initialize your data structure here. */ My ...

  9. 「小程序JAVA实战」小程序视图之条件判断(15)

    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-15/ 小程序里面也是有条件判断的,我相信大家在开发java if和jstl c:if c:when ...

  10. python拷贝目录下的文件

    #!/usr/bin/env python # Version = 3.5.2 import shutil base_dir = '/data/media/' file = '/backup/temp ...