---
title: "ssh配置文件的流程"
author: "dou_shini8820"
date: "2012-07-26T08:55:42Z"
tags: []
categories: ["编程语言"]
slug: "ssh"
draft: false
lastmod: "2012-07-26T08:55:42Z"
id: 1607311
url: "https://doushini.iteye.com/blog/1607311"
---

1.首先肯定是web.xml了，添加一个Spring的listener，让其加载applicationContext\*.xml，然后添加struts的核心控制器，这样项目就知道有spring和struts了，另外可以添加的有：  
中文过滤器CharacterEncodingFilter，  
OpenSessionInViewFilter，  
 配置验证码的servlet，  
Log4jConfigListener，  
会话时间session-config，  
错误提示信息error-page  
权限框架

2.然后就是配置applicationContext.xml了，Spring的核心是事务，首先要开启事务（1.开启注解模式事务 2.开启配置模式事务），事务需要一个sessionFactory，所以需要配置sessionFactory，而其需要一个datasource，所以首选我们需要配置一个datasource；sessionFactory里面有2个属性，还有一个configLocation需要引入hibernate.cfg.xml。

注：  
1.开启注解模式事务  
&lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;  
2.开启配置模式事务  
&lt;tx:advice id="txAdvice" transaction-manager="transactionManager"&gt;  
 &lt;tx:attributes&gt;  
  &lt;tx:method name="get\*" read-only="true" propagation="NOT\_SUPPORTED" /&gt;  
  &lt;tx:method name="find\*" read-only="true" propagation="NOT\_SUPPORTED" /&gt;  
  &lt;tx:method name="\*" propagation="REQUIRED" /&gt;  
 &lt;/tx:attributes&gt;  
&lt;/tx:advice&gt;