一、效果

1.

Struts 2 + Spring2.5 + Hibernate3整合例子_Spring

2.

二、结构

1.

2.用到jar包

antlr-2.7.6.jar
aspectjrt.jar
aspectjweaver.jar
c3p0-0.9.1.jar
cglib-nodep-2.1_3.jar
commons-collections-3.1.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging.jar
dom4j-1.6.1.jar
freemarker-2.3.15.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate3.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
log4j-1.2.15.jar
mysql-connector-java-5.1.7-bin.jar
ognl-2.7.3.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
spring.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar

 

 

三、分析

1.Action层:用struts管理请求,由spring管理action的依赖关系,所以action加上注解@Controller @Scope("prototype"),依赖的service要注解@Resource

2.Service层:要注解@Service @Transactional,依赖的Dao要注解@Resource

 

3.Dao层:要注解@Repository,依赖的SessionFactory要注解@Resource

 

四、代码

1.

2.

3.

4.

5.

 

源代码:

 

You can do anything you set your mind to, man!