• web.xml的配置:
<!--Spring的装载器  -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!--spring的应用上下文,这里也可以用classpath:appli...xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param> <!-- struts2文件拦截器 --> <filter>
<filter-name>struts2</filter-name>
<filter-class>xx.servlet.web.MyStrutsFilterDispatcher</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>xx.bean,xx.dao,xx.quanxin.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
  • applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" default-autowire="byType"> <SPAN style="WHITE-SPACE: pre"> <context:annotation-config/>
<context:component-scan base-package="*" /> <aop:aspectj-autoproxy /> <tx:annotation-driven transaction-manager="transactionManager" /> </SPAN> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"></bean> <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/systeminfo.properties</value>
</property>
</bean> <!-- DBCP数据库连接数据源的配置 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- 把连接重新放到连接池里 -->
<!-- 添加连接池属性 -->
<property name="driverClassName" value="${DB.driverClassName}"/>
<property name="url" value="${DB.server}"/>
<property name="username" value="${DB.username}"/>
<property name="password" value="${DB.password}"/>
<property name="initialSize" value="2" /> <!-- 初始连接数 -->
<property name="maxActive" value="50"/> <!-- 连接池最大连接数 -->
<property name="maxIdle" value="20"/> <!-- 最大的可空闲的连接数 -->
<property name="minIdle" value="10"/> <!-- 最小的可空闲的连接数 -->
<property name="logAbandoned" value="true" /> <!-- 超时后打印超时连接错误 -->
<property name="removeAbandoned" value="true" /> <!-- 超时移除连接 -->
<property name="removeAbandonedTimeout" value="300"/> <!-- 超时时间 -->
<property name="maxWait" value="1000"/> <!-- 最大可以等待时间 -->
<property name="defaultAutoCommit" value="true"/> <!-- 自动提交, -->
</bean> <!-- 将dataSource注入到下面的sessionFactory类里 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>xx/bean/UserInfo.hbm.xml</value>
<value>xx/bean/Role.hbm.xml</value>
</list>
</property>
<!--
通配符加载方式,暂未启用 <property name="mappingLocations"> <list>
<value>classpath:/jy/bean/*.hbm.xml</value> </list> </property>
-->
<property name="hibernateProperties"> <!-- 这里是Properties列表 -->
<props>
<prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop>
<prop key="hibernate.show_sql">true</prop> <!-- 显示sql -->
</props> </property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> </beans>

最新文章

  1. apache on centos
  2. 五、HTML判断输入长度,体会字体颜色变化
  3. Android数据存储的三种方式:SharePreferences , file , SQLite
  4. 关于ScrollView中嵌套listview焦点滑动问题 解决
  5. Section 1.4 The Clocks
  6. JFrame 不规则窗体
  7. Python 中 os.path模板
  8. H.264学习笔记之一(层次结构,NAL,SPS)
  9. 汇编中,BP,SP有何区别?分别怎么使用?
  10. ECSTORE2.0 新增自定义定时任务
  11. 用Ajax读取XML格式的数据
  12. Python学习入门基础教程(learning Python)--8.3 字典常用的方法函数介绍
  13. CentOS安装配置Tomcat7
  14. Motion control encoder extrapolation
  15. asp.net core 中 sql server 2017 数据库连接测试
  16. sshpass的使用方法
  17. 配置ADB到Windows环境变量
  18. Windows登录后不记得密码
  19. JSX
  20. LPC43xx SGPIO I2C Implementation

热门文章

  1. 可见格式化模型BFC与应用
  2. JavaScript图形实例:Canvas API
  3. 06 flask源码剖析之路由加载
  4. 机器学习实战基础(二十四):sklearn中的降维算法PCA和SVD(五) PCA与SVD 之 重要接口inverse_transform
  5. Shaderlab-10chapter-立方体纹理、玻璃效果
  6. day2:Number,tuple,str,list,set,dict
  7. Mysql UDF提权方法
  8. MySql-Binlog协议
  9. 【C#】根据开始时间和结束时间筛选存在的信息
  10. echarts 实战 : 恼人的间隔问题