您的位置:首页 > 编程语言 > Java开发

ssh开发web应用中各个框架的作用以及整合配置步骤

2016-07-17 20:01 661 查看
各个框架的作用:

Spring作为bean对象的管理容器(IOC)

Struts2 作为核心web控制器

Hibernate作为处理数据库的ORM组件

ssh详细配置步骤:

1、 定义数据库连接属性文件

2、 在web.xml中配置log4j日志;spring上下文加载路径以及监听接 口类;struts配置及映射

3、 在spring applicationContext.xml文件中引入数据库属性文件

4、 配置数据源

5、 配置SessionFactory注入数据源

6、 配置事务管理

7、 配置数据库事务处理属性

8、 配置事务aop拦截(事务切面)

9、 定义配置 dao,service,action及其依赖关系

spring上下文加载路径以及监听接口类

<!-- 配置上下文加载读取文件的路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/ssh/jd/conf/spring/applicationContext.xml
</param-value>
</context-param>
<!-- 配置上下文加载监听接口 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>


在web.xml中配置log4j日志

<!-- 配置日志文件加载路径 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>
classpath:com/ssh/jd/conf/log4j.properties
</param-value>
</context-param>
<!-- 配置日志文件加载监听接口类 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息