java整合的ssh框架,如何整合ssh三大框架

当前位置:我的异常网» Java Web开发 » 如何整合ssh三大框架

如何整合ssh三大框架

www.myexceptions.net  网友分享于:2014-06-02  浏览:10次

怎么整合ssh三大框架

我学完了struts2  hibernate  spring  就是不知道怎么整合  求高人赐教

------解决方案--------------------

你搞清楚他们在一起使用的时候各自发挥的功能吧,具体整合一块只是配置问题了,主要是理解SSH的优势

------解决方案--------------------

这个真的不是一下子给说清楚的。网上确实有很多这方面的介绍。你去下载看看吧。步骤来说:

1,是包加入

2,配置好

3,测试一下。

这些步骤最复杂的应该是配置。

如果你用高版本的注解可能会省很多配置方便很多。

------解决方案--------------------

spring主要用来依赖注入,比如把DAO注入到service,spring还用来进行事务管理。

hibernate当然是负责数据库的操作,增删改查。。。

strtus2是实现MVC的框架,和web打交道,页面参数的获取,验证,以及跳转页面等...

------解决方案--------------------

第一步:导入SSH相关jar包和数据库jar包

第二步:编写配置文件

1. 编写sping配置文件

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="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">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

classpath:jdbc.properties

class="org.apache.commons.dbcp.BasicDataSource">

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"

id="sessionFactory">

org.hibernate.dialect.MySQL5Dialect

true

true

update

com.sls.entity

id="hibernateTemplate">

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

2.编写jdbc.properties

jdbc.driverClassName=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/myDataBase

jdbc.username=root

jdbc.password=root

3.编写Struts2.xml

struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

/list.jsp

4. 编写web.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

contextConfigLocation

classpath:beans.xml

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值