一. SSH 所应用到的包文件
ssh搭建完成项目url=http://d.download.csdn.net/down/1287448/eluyouni
Spring2.5中的包
spring.jar
spring-webmvc-struts.jar
commons-pool.jar
commons-logging.jar
commons-dbcp.jar
common-annotations.jar
cglib-nodep-2.1_3.jar
aspectjweaver.jar
aspectjrt.jar
antlr-2.7.6.jar
log4j-1.2.15.jar
Hibernate3.3中的包
slf4j-api-1.5.2.jar
jta-1.1.jar
javassist-3.4.GA.jar
hibernate3.jar
ehcache-1.2.3.jar
dom4j-1.6.1.jar
commons-collections-3.1.jar
antlr-2.7.6.jar
Struts1.3 中的包
bsf-2.3.0.jar
commons-beanutils-1.8.0.jar
commons-chain-1.2.jar
commons-digester-1.8.jar
commons-io-1.1.jar
commons-fileupload-1.1.1.jar
commons-logging-1.0.4.jar
commons-validator-1.3.1.jar
jstl-1.2.jar
oro-2.0.8.jar
standard-1.1.2.jar
struts-core-1.3.10.jar
struts-el-1.3.10.jar
struts-extras-1.3.10.jar
struts-faces-1.3.10.jar
struts-mailreader-dao-1.3.10.jar
struts-scripting-1.3.10.jar
struts-taglib-1.3.10.jar
struts-tiles-1.3.10.jar
二.配置文件
-------------------------
web.xml文件配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-hibernate.xml</param-value>
</context-param>
<!-- 对Spring 容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- ssh 中文过滤 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 延迟加载问题
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<!-- 配置 Struts 核心控制器 -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
----------------------------------------
struts-config.xml 配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings >
<!-- type="com.hf.ssh.struts.action.PersonAction" 可有可无 有type属性时 当spring找不到/person 时将 把控制权交还给struts -->
<action path="/person" type="com.hf.ssh.struts.action.PersonAction" validate="false">
<forward name="personlist" path="/WEB-INF/page/personlist.jsp" />
</action>
</action-mappings>
<!-- 控制器 -->
<controller>
<!-- 定义请求处理器 的 类来自 spring-webmvc-struts.jar -->
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor" />
</controller>
<message-resources parameter="com.hf.ssh.struts.ApplicationResources" />
</struts-config>
-------------------------------------------
applicationContext-hibernate.xml 配置 Spring集成Hibernate 事物管理和注入都是采用注解的方式
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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
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/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd ">
<!-- 通过注解方式 注入 -->
<context:annotation-config />
<!-- MySql数据库(连接池)连接 -->
<!-- 使用commons-dbcp.jar 内的BasicDataSource类
指定dataSource数据源对象 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/hf_shop?useUnicode=true&characterEncoding=UTF-8" />
<property name="username" value="root" />
<property name="password" value="1"/>
<!-- 连接池启动时的初始值 -->
<property name="initialSize" value="1" />
<!-- 连接池最大值 -->
<property name="maxActive" value="500" />
<!-- 最大空闲值 当经历过一次高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
<property name="maxIdle" value="2" />
<!-- 最小空闲值 当空闲的连接数减少至一定值时,连接池会预定申请去连接一些以免来不及供应-->
<property name="minIdle" value="1" />
</bean>
<!-- Spring.jar包 管理hibernate -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/hf/ssh/entity/Bb.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2dd1.auto=update
hibernate.show_sql =false
hibernate.format_sql = false
</value>
</property>
</bean>
<!-- spring.jar内的 DataSourceTransactionManager类 配置事务管理器(采用注解方式) -->
<bean id="hfManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 注解方式 事务管理 -->
<tx:annotation-driven transaction-manager="hfManager"/>
<bean id="personService" class="com.hf.ssh.service.impl.PersonServiceImpl"> </bean>
<!-- Spring管理 struts -->
<bean name="/person" class="com.hf.ssh.struts.action.PersonAction"></bean>
</beans>
------------------------------
Bb.hbm.xml 配置文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.hf.ssh.entity">
<class name="Bb" table="bb">
<id name="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="name" length="20" not-null="true" />
<property name="password" length="20" not-null="true" />
</class>
</hibernate-mapping>
--------------------------------------------------------------
注意:spring开发团队提倡大家使用注解方式实现 依赖注入 和 事务管理
将包导入lib目录配置文件配置好并填写相应的service 和 dao 集成即可完成
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ELuYouNi/archive/2009/05/08/4162099.aspx
相关推荐
Spring2.5+Hibernate3.3+strut2整合开发案例,亲自测试过,对于新手学习如何进行ssh整合开发有很大帮助
SSH整合spring3.2+strut2.3.4+hibernate4.2所需jar包,没分下载这上面有的,花了一个下午收集齐全打包分享
ssh(spring+strut1.x+hibernate)整合完整教程word版 附带包
经过一天时间把SSH整合了, 包里有三大框架最基础的jar, 没有这些, tomcat运行就报错. 另要加其他插件和功能, 请自行添加
这是一个实际使用中的项目,可访问 http://cdbke.cuit.edu.cn 可查看效果及功能,后台需要登录后才能使用(出于安全性考虑这里就不给大家介绍了,另外还有一个struts1版本的,如有需要可以与我联系)。...
此是完整的三大框架项目 环境: Myeclipse 8.6M1 Tomcat 6.0 Mysql 5.2 JDK 1.6 注:因你的数据库不一样,需要更改applicationContext.xml中的dataSource 项
此项目主要是实现struts1/struts2+spring2.5+hibernate3.0的整合
spring3.2+strut2+hibernate4 注解方式。 spring.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=...
ssh三大框架的整合步骤,非常详细。包含spring整合struts、spring整合hibernate、声明式事务说明等。
Strut+Spring+Hibernate框架的工作原理 非常详细 适合初学者和有一定经验的编程人员
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
struts2.3.4+spring3.2.0+hibernate4+hibernate_generic_dao struts hibernate spring最大化使用注释 基于spring的远程调用
strut+spring+hibernate注册登录系统,包括管理员登录,管理员对普通用户的增删改查;用户的注册,登录!对初学SSH框架的有很大的帮助!
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
很全的ssh整合的案例,有疑惑的看完绝对豁然开朗
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
bootstrap、spring mvc+spring+hibernate+maven架构搭建,实现简单的查询用户查询功能
这是一个基于ssh框架的小项目。适合于刚接触ssh框架的朋友学习。
构建strut2+spring3+hibernate4所有jar,直接导入lib,进行相关配置