多语言展示
当前在线:399今日阅读:60今日分享:41

Java--SSH三大框架整合步骤

新手入门级别的三大框架整合,想必学习Java网站开发的程序员都经历过三大框架整合的难题,现在我这儿有三大框架整合的基本步骤,分享给大家!
工具/原料
1

Java环境

2

SSH的基本包

方法/步骤
1

spring整合hibernate加入jar包加入spring和aop所需必须包加入hibernate的必须包spring整合hibernate的必须包org.springframework.jdbc-3.1.3.RELEASE.jarorg.springframework.orm-3.1.3.RELEASE.jarorg.springframework.transaction-3.1.3.RELEASE.jar

2

加入配置文件加入spring的配置文件加入hibernate的配置文件

3

加入配置代码加入对SessionFactory的配置加入数据源(DataSource)的配置       加入SessionFactory的配置     com/direct/domain/Employee.hbm.xml com/direct/domain/Log.hbm.xml 加入事务管理切面类的配置             将切面类应用到切入点上          

4

spring和struts2的整合加入整合包加入struts的必须包struts整合spring的包struts2-spring-plugin-2.3.15.3.jarspring整合struts的包org.springframework.web-3.1.3.RELEASE.jarorg.springframework.web.servlet-3.1.3.RELEASE.jarorg.springframework.web.struts-3.1.3.RELEASE.jar

5

加入struts的配置文件struts.xml

6

在web.xml中配置struts   struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 /*

7

在web.xml配置spring   contextConfigLocation classpath*:applicationContext-*.xml org.springframework.web.context.ContextLoaderListener

8

在struts.xml中配置对象创建工具为spring       

注意事项

在struts中配置action时需要将class设置为action在spring中配置的id名,而不能使用类的全名

推荐信息