zhangjingqiang's Blog
BlogJava
首页
新随笔
新文章
联系
聚合
管理
posts - 5, comments - 0, trackbacks - 0
Struts+Spring+Hibernate集成简单配置
applicationContext.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"
>
3
<
beans
>
4
<
bean
id
="dataSource"
5
class
="org.apache.commons.dbcp.BasicDataSource"
>
6
<
property
name
="driverClassName"
>
7
<
value
>
com.mysql.jdbc.Driver
</
value
>
8
</
property
>
9
<
property
name
="url"
>
10
<
value
>
jdbc:mysql://localhost:3306/j2ee
</
value
>
11
</
property
>
12
<
property
name
="username"
>
13
<
value
>
root
</
value
>
14
</
property
>
15
</
bean
>
16
<
bean
id
="sessionFactory"
17
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
18
<
property
name
="dataSource"
>
19
<
ref
bean
="dataSource"
/>
20
</
property
>
21
<
property
name
="hibernateProperties"
>
22
<
props
>
23
<
prop
key
="hibernate.dialect"
>
24
org.hibernate.dialect.MySQLDialect
25
</
prop
>
26
</
props
>
27
</
property
>
28
<
property
name
="mappingResources"
>
29
<
list
>
30
<
value
>
org/me/sshdemo/db/Usertable.hbm.xml
</
value
>
31
</
list
>
32
</
property
>
33
</
bean
>
34
<
bean
id
="UsertableDAO"
class
="org.me.sshdemo.dao.UsertableDAO"
>
35
<
property
name
="sessionFactory"
>
36
<
ref
bean
="sessionFactory"
/>
37
</
property
>
38
</
bean
>
39
<
bean
name
="/input"
class
="org.me.sshdemo.action.InputAction"
40
abstract
="false"
singleton
="false"
lazy-init
="default"
41
autowire
="default"
dependency-check
="default"
>
42
<
property
name
="usertableDao"
>
43
<
ref
bean
="UsertableDAO"
/>
44
</
property
>
45
</
bean
>
46
<
bean
name
="/selectAllUsers"
47
class
="org.me.sshdemo.action.SelectAllUsersAction"
abstract
="false"
48
singleton
="false"
lazy-init
="default"
autowire
="default"
49
dependency-check
="default"
>
50
<
property
name
="usertableDao"
>
51
<
ref
bean
="UsertableDAO"
/>
52
</
property
>
53
</
bean
>
54
</
beans
>
struts-config.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"
>
3
<
struts-config
>
4
<
data-sources
/>
5
<
form-beans
>
6
<
form-bean
name
="inputForm"
type
="org.me.sshdemo.db.Usertable"
/>
7
</
form-beans
>
8
<
global-exceptions
/>
9
<
global-forwards
/>
10
<
action-mappings
>
11
<
action
attribute
="inputForm"
input
="/input.jsp"
12
name
="inputForm"
path
="/input"
scope
="request"
13
type
="org.springframework.web.struts.DelegatingActionProxy"
>
14
<
forward
name
="selectAllUsers"
path
="/selectAllUsers.do"
15
redirect
="true"
/>
16
</
action
>
17
<
action
path
="/selectAllUsers"
18
type
="org.springframework.web.struts.DelegatingActionProxy"
>
19
<
forward
name
="output"
path
="/output.jsp"
redirect
="true"
/>
20
</
action
>
21
</
action-mappings
>
22
<
message-resources
parameter
="org.me.sshdemo.ApplicationResources"
/>
23
<
plug-in
24
className
="org.springframework.web.struts.ContextLoaderPlugIn"
>
25
<
set-property
property
="contextConfigLocation"
26
value
="/WEB-INF/applicationContext.xml"
/>
27
</
plug-in
>
28
</
struts-config
>
Usertable.hbm.xml
1
<?
xml version="1.0" encoding="utf-8"
?>
2
<!
DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
3
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
4
<!--
5
Mapping file autogenerated by MyEclipse - Hibernate Tools
6
-->
7
<
hibernate-mapping
>
8
<
class
name
="org.me.sshdemo.db.Usertable"
table
="usertable"
>
9
<
id
name
="userid"
type
="java.lang.Integer"
>
10
<
column
name
="userid"
/>
11
<
generator
class
="native"
/>
12
</
id
>
13
<
property
name
="username"
type
="java.lang.String"
>
14
<
column
name
="username"
length
="20"
/>
15
</
property
>
16
<
property
name
="userpwd"
type
="java.lang.String"
>
17
<
column
name
="userpwd"
length
="20"
/>
18
</
property
>
19
</
class
>
20
</
hibernate-mapping
>
完整程序:http://zhangjingqiang.javaeye.com/blog/51798
posted on 2007-02-05 10:49
zhangjingqiang
阅读(1381)
评论(0)
编辑
收藏
所属分类:
Struts
、
Hibernate
、
Spring
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
相关文章:
基于Struts+Spring+Hibernate的Blog系统--配置
Struts+Spring+Hibernate集成简单配置
<
2007年2月
>
日
一
二
三
四
五
六
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
常用链接
我的随笔
我的评论
我的参与
留言簿
(1)
给我留言
查看公开留言
查看私人留言
随笔分类
Ajax(1)
Hibernate(4)
iBATIS(1)
Spring(5)
Struts(2)
WebWork(1)
随笔档案
2007年2月 (5)
收藏夹
技术博客(1)
友情链接
搜索
积分与排名
积分 - 3669
排名 - 3374
最新评论
阅读排行榜
1. Struts+Spring+Hibernate集成简单配置(1381)
2. 基于Ajax+Spring+Hibernate的用户管理系统--配置(692)
3. 基于Spring+WebWork+iBATIS的游戏装备交易系统--配置(664)
4. 基于Struts+Spring+Hibernate的Blog系统--配置(563)
5. 基于Spring+Hibernate的网上广告管理系统--配置(317)
评论排行榜
1. 基于Ajax+Spring+Hibernate的用户管理系统--配置(0)
2. 基于Spring+WebWork+iBATIS的游戏装备交易系统--配置(0)
3. 基于Spring+Hibernate的网上广告管理系统--配置(0)
4. 基于Struts+Spring+Hibernate的Blog系统--配置(0)
5. Struts+Spring+Hibernate集成简单配置(0)