sturts2+hibernate3+spring3Word文件下载.docx
《sturts2+hibernate3+spring3Word文件下载.docx》由会员分享,可在线阅读,更多相关《sturts2+hibernate3+spring3Word文件下载.docx(18页珍藏版)》请在冰豆网上搜索。
![sturts2+hibernate3+spring3Word文件下载.docx](https://file1.bdocx.com/fileroot1/2022-11/16/ebe941ea-60c2-4d7a-9952-4d5b860401fa/ebe941ea-60c2-4d7a-9952-4d5b860401fa1.gif)
beansxmlns="
http:
//www.springframework.org/schema/beans"
xmlns:
xsi="
//www.w3.org/2001/XMLSchema-instance"
context="
//www.springframework.org/schema/context"
tx="
//www.springframework.org/schema/tx"
xsi:
schemaLocation="
//www.springframework.org/schema/beans
http:
//www.springframework.org/schema/beans/spring-beans-3.0.xsd
//www.springframework.org/schema/context
//www.springframework.org/schema/context/spring-context-3.0.xsd
//www.springframework.org/schema/tx
//www.springframework.org/schema/tx/spring-tx-3.0.xsd"
<
!
--配置数据源-->
<
beanid="
dataSource"
class="
mons.dbcp.BasicDataSource"
destroy-method="
close"
propertyname="
driverClassName"
value="
com.mysql.jdbc.Driver"
/>
url"
jdbc:
mysql:
//localhost:
3306/fl"
/>
username"
root"
password"
P@ssw0rd"
--连接池启动时的初始值-->
initialSize"
1"
--连接池的最大值-->
maxActive"
500"
--最大空闲值,当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接释放,一直减少到msxIdle为止-->
maxIdle"
2"
--最小空闲值,当空闲的连接数小于阀值时,连接池就会预申请一些连接,以免洪峰到来时来不及申请-->
minIdle"
/bean>
sessionFactory"
org.springframework.orm.hibernate3.LocalSessionFactoryBean"
ref="
mappingResources"
list>
value>
net/gicp/caihaobin/dto/UserInfo.hbm.xml<
/value>
/list>
/property>
hibernateProperties"
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
--配置事务管理器-->
txManager"
org.springframework.orm.hibernate3.HibernateTransactionManager"
<
context:
annotation-config/>
tx:
annotation-driventransaction-manager="
userInfoDaoImpl"
net.gicp.caihaobin.dao.impl.UserInfoDaoImpl"
beanname="
baseAction"
net.gicp.caihaobin.base.BaseAction"
userinfo"
net.gicp.caihaobin.action.UserAction"
parent="
/beans>
数据库的表结构如下:
mysql>
descuserinfo;
+-----------+-------------+------+-----+---------+----------------+
|Field|Type|Null|Key|Default|Extra|
|uid|int(11)|NO|PRI|NULL|auto_increment|
|uName|varchar(50)|NO||NULL||
|uPassword|varchar(50)|NO||NULL||
|uSex|varchar(50)|NO||NULL||
|uQue1|varchar(50)|NO||NULL||
|uAns1|varchar(50)|NO||NULL||
|uQue2|varchar(50)|NO||NULL||
|uAns2|varchar(50)|NO||NULL||
|uHead|varchar(50)|NO||NULL||
|uMessage|varchar(50)|NO||NULL||
src目录下新建一个package:
net.gicp.caihaobin.dto
在此包下新建UserInfo.java
packagenet.gicp.caihaobin.dto;
importcom.google.gson.annotations.Expose;
publicclassUserInfo{
@Expose
privateintuid;
privateStringuName;
privateStringuPassword;
privateStringuSex;
privateStringuQue1;
privateStringuAns1;
privateStringuQue2;
privateStringuAns2;
privateStringuHead;
privateStringuMessage;
publicintgetUid(){
returnuid;
}
publicvoidsetUid(intuid){
this.uid=uid;
publicStringgetuName(){
returnuName;
publicvoidsetuName(StringuName){
this.uName=uName;
publicStringgetuPassword(){
returnuPassword;
publicvoidsetuPassword(StringuPassword){
this.uPassword=uPassword;
publicStringgetuSex(){
returnuSex;
publicvoidsetuSex(StringuSex){
this.uSex=uSex;
publicStringgetuQue1(){
returnuQue1;
publicvoidsetuQue1(StringuQue1){
this.uQue1=uQue1;
publicStringgetuAns1(){
returnuAns1;
publicvoidsetuAns1(StringuAns1){
this.uAns1=uAns1;
publicStringgetuQue2(){
returnuQue2;
publicvoidsetuQue2(StringuQue2){
this.uQue2=uQue2;
publicStringgetuAns2(){
returnuAns2;
publicvoidsetuAns2(StringuAns2){
this.uAns2=uAns2;
publicStringgetuHead(){
returnuHead;
publicvoidsetuHead(StringuHead){
this.uHead=uHead;
publicStringgetuMessage(){
returnuMessage;
p