java7整合框架ssh,SSH框架的集成步骤

S2SH框架集成步骤:

1、框架依赖jar文件

(这些jar包可以去官网自己下载,地址不在连接)

1.1 sping     所依赖工程 spring-framework-2.5.6

dist\spring.jar

lib\cglib\cglib-nodep-2.1_3.jar

lib\jakarta-commons\commons-logging.jar

lib\aspectj\aspectjweaver.jar和aspectjrt.jar      lib\j2ee\common-annotations.jar

1.2 hibernate   所依赖工程 hibernate-distribution-3.3.2.GA

hibernate3.jar

lib\required\jta-1.1.jar        javassist-3.9.0.GA.jar        dom4j-1.6.1.jar        commons-collections-3.1.jar        antlr-2.7.6.jar        slf4j-api-1.5.8.jar

lib\bytecode\cglib\cglib-2.2.jar

[二级缓存可选]lib\optional\oscache\oscache-2.1.jar        同时需要把\project\etc\oscache.properties 拷贝到src 下

[二级缓存可选]lib\optional\ehcache\ehcache-1.2.3.jar  同时需要把\project\etc\ehcache.xml

[二级缓存可选]lib\optional\c3p0\    配置c3p0数据库连接池的使用 作用等同于apache的dbcp

*使用hibernate注解:hibernate-annotations-3.4.0.GA\

hibernate-annotations.jar

lib\hibernate-commons-annotations.jar

lib\ejb3-persistence.jar

*若使用slf的日志还需要:slf4j-1.5.8

slf4j-nop-1.5.8.jar

1.3 struts2  所依赖工程  struts-2.1.8.1

lib目录下的:

struts2-core-2.1.8.1.jar

xwork-core-2.1.6.jar

ognl-2.7.3.jar

freemarker-2.3.15.jar

commons-fileupload-1.2.1.jar

commons-io-1.3.2.jar

struts2-spring-plugin-2.1.8.1.jar

aopalliance-1.0.jar

classworlds-1.1.jar

commons-beanutils-1.7.0.jar

commons-chain-1.2.jar

commons-collections-3.2.jar  在hibernate中已经引用

commons-digester-2.0.jar

commons-lang-2.3.jar

commons-logging-1.0.4.jar  此文件在spring中已存在

commons-logging-api-1.1.jar

commons-validator-1.3.1.jar

ezmorph-1.0.3.jar

json-lib-2.1.jar 若使用json可选

oro-2.0.8.jar

oval-1.31.jar

2、框架的配置文件

2.1 spring框架配置文件及集成hibernate、二级缓存

$WEB_ROOT/WEB-INF/applicationContext.xml

src/ehcache.xml

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

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

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

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

xsi:schemaLocation="http://www.springframework.org/schema/beans

">

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

destroy-method="close">

cn/tsp2c/sshdemo/domain/User.hbm.xml

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

hibernate.hbm2ddl.auto=update

hibernate.show_sql=false

hibernate.format_sql=false

hibernate.cache.use_second_level_cache=true

hibernate.cache.use_query_cache=false

hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

其中集成hibernate需要属性文件:jdbc4mysql.properties

driverClassName=com.mysql.jdbc.Driver

url=jdbc\:mysql\://localhost\:3306/sshdemodb?useUnicode\=true&characterEncoding\=utf-8

username=root

password=1234

initialSize=1

maxActive=500

maxIdle=2

minIdle=1

需要配置hibernate的二级缓存,如使用ehcache:在src路径下加入ehcache.xml

timeToIdleSeconds="120"

timeToLiveSeconds="180"

diskPersistent="false"

diskExpiryThreadIntervalSeconds="60"/>

overflowToDisk="true" timeToIdleSeconds="300" timeToLiveSeconds="500" diskPersistent="false"/>

2.2 struts2的配置文件: src/struts.xml

/p>

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

"">

/WEB-INF/page/message.jsp

/WEB-INF/page/error.jsp

/index.jsp

/login.jsp

/userlist.jsp

/useradd.jsp

3、需要把spring、strusts2框架注入到web容器(hibernate框架被spring集成,和web容器没有关系。所以不需要在web.xml中配置)

web.xml文件:

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

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

">

contextConfigLocation

/WEB-INF/applicationContext.xml

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2

/*

org.springframework.web.context.ContextLoaderListener

index.jsp

3.1 web容器集成spring

contextConfigLocation

/WEB-INF/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

3.2 web容器集成struts2

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2

/*

3.3 关于在session范围内解决hibernate的延迟加载问题

HibernateSessionInViewFilter

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

HibernateSessionInViewFilter

/*

4、如何使用s2sh框架实现MVC

4.1 action

struts.xml:

/userlist.jsp

/useradd.jsp

在spring中配置:

4.2 service

4.3 dao

posted on 2011-03-25 20:18 Soap MacTavish 阅读(3164) 评论(1)  编辑  收藏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值