Strutsspringhibernate-免积分.doc

上传人:hw****26 文档编号:3552902 上传时间:2019-06-04 格式:DOC 页数:24 大小:148KB
下载 相关 举报
Strutsspringhibernate-免积分.doc_第1页
第1页 / 共24页
Strutsspringhibernate-免积分.doc_第2页
第2页 / 共24页
Strutsspringhibernate-免积分.doc_第3页
第3页 / 共24页
Strutsspringhibernate-免积分.doc_第4页
第4页 / 共24页
Strutsspringhibernate-免积分.doc_第5页
第5页 / 共24页
点击查看更多>>
资源描述

1、SSH 整合整合以 spring 为容器,管理 hibernate 的 DAO 和 Struts2 的 Action。一、 准备工作Struts2.06+spring2.5+hibernate3.2+jdk6.0+myeclipse6.0+tomcat5.5+mysql5.0以上是整合的原料。下面以一个注册登陆的例子来开始我们的整合过程。这个例子很简单,下面是它的 sql 脚本内容:Create TABLE user (userid int(11) NOT NULL AUTO_INCREMENT,username varchar(20) NOT NULL,password varchar(16

2、) NOT NULL,email varchar(30) NOT NULL,PRIMARY KEY (userid) ENGINE=InnoDB DEFAULT CHARSET=utf-8;二、 开始行动包结构可以参考下图图一图二图三1) Struts 部分 :建立 struts.xml 和 struts.propertiesStruts.xml 内容如下:/error.jsp/success.jsp /login.jsp/success.jsp /regist.jspStruts.properties 内容如下:struts.devMode=falsestruts.enable.Dynami

3、cMethodInvocation=truestruts.i18n.reload=truestruts.ui.theme=simplestruts.locale=zh_CNstruts.i18n.encoding=UTF-8struts.objectFactory=springstruts.objectFactory.spring.autoWire=namestruts.serve.static.browserCache=falsestruts.url.includeParams=none2) 建立 User.java 和 User.hbm.xml、jdbc.properties:User.j

4、ava 内容如下:/* */* * * author flustar* version 1.0 * Creation date: Dec 23, 2007 1:55:28 PM*/package com.firstssh.model;import java.io.Serializable;public class User implements Serializable private int id;private String username;private String password;private String email;public int getId() return id;

5、public void setId(int id) this.id = id;public String getUsername() return username;public void setUsername(String username) this.username = username;public String getPassword() return password;public void setPassword(String password) this.password = password;public String getEmail() return email;pub

6、lic void setEmail(String email) this.email = email;User.hbm.xml 内容:jdbc.properties 内容如下:datasource.type=mysqldatasource.driverClassName=com.mysql.jdbc.Driverdatasource.url=jdbc:mysql:/localhost:3306/test?useUnicode=true&characterEncoding=UTF-8datasource.username=rootdatasource.password=123456datasou

7、rce.maxActive=10datasource.maxIdle=2datasource.maxWait=120000datasource.whenExhaustedAction=1datasource.validationQuery=select 1 from dualdatasource.testOnBorrow=truedatasource.testOnReturn=falsec3p0.acquireIncrement=3c3p0.initialPoolSize=3c3p0.idleConnectionTestPeriod=900c3p0.minPoolSize=2c3p0.maxP

8、oolSize=50c3p0.maxStatements=100c3p0.numHelperThreads=10c3p0.maxIdleTime=600hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect#hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialecthibernate.jdbc.batch_size=25hibernate.jdbc.fetch_size=50hibernate.show_sql=truehibernate.connection.release

9、_mode=after_transaction3) Spirng 部分:为了清晰把 Spring 的配置文件拆分成以下几部分 applicationContext-dao.xml、 appliationContext-service.xml、applicationContext-hibernate.xml、action- servlet.xml。applicationContext-hibernate.xml 内容:WEB-INF/mail.propertiesWEB-INF/jdbc.propertiesWEB-INF/oscache.properties$datasource.driver

10、ClassName$datasource.url$datasource.username$datasource.password$c3p0.acquireIncrement$c3p0.initialPoolSize$c3p0.minPoolSize$c3p0.maxPoolSize$c3p0.maxIdleTime$c3p0.idleConnectionTestPeriod$c3p0.maxStatements$c3p0.numHelperThreadscom/firstssh/model/User.hbm.xml$hibernate.dialect$hibernate.show_sql$hi

11、bernate.jdbc.fetch_size$hibernate.jdbc.batch_sizePROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIREDPROPAGATION_REQUIRED,readOnlyPROPAGATION_REQUIRED,readOnlyPROPAGATION_REQUIRED,readOnlyPROPAGATION_REQUIREDPROPAGATION_REQUIRED,readOnlyuserServicetransactionInterceptorapplicationContext-dao.xml 内容:applicationContext-service.xml 内容:

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 精品笔记

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。