zhangjingqiang's Blog
BlogJava
首页
新随笔
新文章
联系
聚合
管理
posts - 5, comments - 0, trackbacks - 0
基于Struts+Spring+Hibernate的Blog系统--配置
applicationContext.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
3
"http://www.springframework.org/dtd/spring-beans.dtd"
>
4
5
<
beans
>
6
<
bean
id
="propertyConfigurer"
7
class
="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
8
<
property
name
="location"
value
="classpath:jdbc.properties"
/>
9
</
bean
>
10
11
<!--
Transaction template for Managers, from:
12
http://blog.exis.com/colin/archives/2004/07/31/concise-transaction-definitions-spring-11/
-->
13
<
bean
id
="txProxyTemplate"
abstract
="true"
14
class
="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
>
15
<
property
name
="transactionManager"
>
16
<
ref
bean
="transactionManager"
/>
17
</
property
>
18
<
property
name
="transactionAttributes"
>
19
<
props
>
20
<
prop
key
="save*"
>
PROPAGATION_REQUIRED
</
prop
>
21
<
prop
key
="remove*"
>
PROPAGATION_REQUIRED
</
prop
>
22
<
prop
key
="*"
>
PROPAGATION_REQUIRED,readOnly
</
prop
>
23
</
props
>
24
</
property
>
25
</
bean
>
26
27
<
bean
id
="userManager"
parent
="txProxyTemplate"
>
28
<
property
name
="target"
>
29
<
bean
class
="com.weblog.service.impl.UserManagerImpl"
>
30
<
property
name
="userDAO"
ref
="userDAO"
/>
31
</
bean
>
32
</
property
>
33
</
bean
>
34
<!--
Author-START
-->
35
<
bean
id
="authorManager"
parent
="txProxyTemplate"
>
36
<
property
name
="target"
>
37
<
bean
class
="com.weblog.service.impl.AuthorManagerImpl"
>
38
<
property
name
="authorDao"
ref
="authorDao"
/>
39
</
bean
>
40
</
property
>
41
</
bean
>
42
<!--
Author-END
-->
43
<!--
Category-START
-->
44
<
bean
id
="categoryManager"
parent
="txProxyTemplate"
>
45
<
property
name
="target"
>
46
<
bean
class
="com.weblog.service.impl.CategoryManagerImpl"
>
47
<
property
name
="categoryDao"
ref
="categoryDao"
/>
48
</
bean
>
49
</
property
>
50
</
bean
>
51
<!--
Category-END
-->
52
<!--
Weblog-START
-->
53
<
bean
id
="weblogManager"
parent
="txProxyTemplate"
>
54
<
property
name
="target"
>
55
<
bean
class
="com.weblog.service.impl.WeblogManagerImpl"
>
56
<
property
name
="weblogDao"
ref
="weblogDao"
/>
57
</
bean
>
58
</
property
>
59
</
bean
>
60
<!--
Weblog-END
-->
61
62
</
beans
>
action-servlet.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
3
"http://www.springframework.org/dtd/spring-beans.dtd"
>
4
5
<
beans
>
6
<
bean
name
="/user"
class
="com.weblog.web.UserAction"
7
singleton
="false"
>
8
<
property
name
="userManager"
ref
="userManager"
/>
9
</
bean
>
10
<
bean
name
="/author"
class
="com.weblog.web.AuthorAction"
11
singleton
="false"
>
12
<
property
name
="authorManager"
ref
="authorManager"
/>
13
</
bean
>
14
<
bean
name
="/category"
class
="com.weblog.web.CategoryAction"
15
singleton
="false"
>
16
<
property
name
="categoryManager"
ref
="categoryManager"
/>
17
</
bean
>
18
<
bean
name
="/weblog"
class
="com.weblog.web.WeblogAction"
19
singleton
="false"
>
20
<
property
name
="weblogManager"
ref
="weblogManager"
/>
21
</
bean
>
22
</
beans
>
applicationContext-hibernate.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
3
"http://www.springframework.org/dtd/spring-beans.dtd"
>
4
5
<
beans
>
6
<
bean
id
="dataSource"
7
class
="org.springframework.jdbc.datasource.DriverManagerDataSource"
>
8
<
property
name
="driverClassName"
9
value
="${jdbc.driverClassName}"
/>
10
<
property
name
="url"
value
="${jdbc.url}"
/>
11
<
property
name
="username"
value
="${jdbc.username}"
/>
12
<
property
name
="password"
value
="${jdbc.password}"
/>
13
</
bean
>
14
15
<
bean
id
="sessionFactory"
16
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
17
<
property
name
="dataSource"
ref
="dataSource"
/>
18
<
property
name
="mappingResources"
>
19
<
list
>
20
<
value
>
com/weblog/model/User.hbm.xml
</
value
>
21
<
value
>
com/weblog/model/Author.hbm.xml
</
value
>
22
<
value
>
com/weblog/model/Category.hbm.xml
</
value
>
23
<
value
>
com/weblog/model/Weblog.hbm.xml
</
value
>
24
</
list
>
25
</
property
>
26
<
property
name
="hibernateProperties"
>
27
<
props
>
28
<
prop
key
="hibernate.dialect"
>
29
org.hibernate.dialect.PostgreSQLDialect
30
</
prop
>
31
<
prop
key
="hibernate.hbm2ddl.auto"
>
update
</
prop
>
32
</
props
>
33
</
property
>
34
</
bean
>
35
36
<
bean
id
="transactionManager"
37
class
="org.springframework.orm.hibernate3.HibernateTransactionManager"
>
38
<
property
name
="sessionFactory"
ref
="sessionFactory"
/>
39
</
bean
>
40
41
<
bean
id
="userDAO"
42
class
="com.weblog.dao.hibernate.UserDAOHibernate"
>
43
<
property
name
="sessionFactory"
ref
="sessionFactory"
/>
44
</
bean
>
45
<
bean
id
="authorDao"
46
class
="com.weblog.dao.hibernate.AuthorDaoHibernate"
>
47
<
property
name
="sessionFactory"
ref
="sessionFactory"
/>
48
</
bean
>
49
50
<
bean
id
="categoryDao"
51
class
="com.weblog.dao.hibernate.CategoryDaoHibernate"
52
autowire
="byName"
/>
53
<
bean
id
="weblogDao"
54
class
="com.weblog.dao.hibernate.WeblogDaoHibernate"
>
55
<
property
name
="sessionFactory"
ref
="sessionFactory"
/>
56
</
bean
>
57
58
</
beans
>
jdbc.properties
1
jdbc.driverClassName=org.postgresql.Driver
2
jdbc.url=jdbc:postgresql://localhost/weblog
3
jdbc.username=postgres
4
jdbc.password=password
struts-config.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE struts-config PUBLIC
3
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
4
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"
>
5
6
<
struts-config
>
7
8
<!--
======================================== Form Bean Definitions
-->
9
10
<
form-beans
>
11
<
form-bean
name
="userForm"
12
type
="org.apache.struts.validator.DynaValidatorForm"
>
13
<
form-property
name
="user"
type
="com.weblog.model.User"
/>
14
</
form-bean
>
15
<
form-bean
name
="authorForm"
16
type
="org.apache.struts.validator.DynaValidatorForm"
>
17
<
form-property
name
="author"
type
="com.weblog.model.Author"
/>
18
</
form-bean
>
19
<
form-bean
name
="categoryForm"
20
type
="org.apache.struts.validator.DynaValidatorForm"
>
21
<
form-property
name
="category"
22
type
="com.weblog.model.Category"
/>
23
</
form-bean
>
24
<
form-bean
name
="weblogForm"
25
type
="org.apache.struts.validator.DynaValidatorForm"
>
26
<
form-property
name
="weblog"
type
="com.weblog.model.Weblog"
/>
27
</
form-bean
>
28
</
form-beans
>
29
30
<!--
=================================== Global Exception Definitions
-->
31
<
global-exceptions
>
32
<
exception
key
="error.required"
33
type
="org.springframework.dao.DataAccessException"
34
path
="/dataAccessFailure.jsp"
/>
35
</
global-exceptions
>
36
37
<!--
=================================== Global Forward Definitions
-->
38
39
<
global-forwards
>
40
<
forward
name
="users"
path
="/users.html"
redirect
="true"
/>
41
<
forward
name
="authors"
path
="/authors.html"
redirect
="true"
/>
42
<
forward
name
="weblogs"
path
="/weblogs.html"
redirect
="true"
/>
43
<
forward
name
="categorys"
path
="/categorys.html"
44
redirect
="true"
/>
45
</
global-forwards
>
46
47
<!--
=================================== Action Mapping Definitions
-->
48
49
<
action-mappings
>
50
51
<
action
path
="/users"
52
type
="org.apache.struts.actions.ForwardAction"
53
parameter
="/user.html"
/>
54
55
<
action
path
="/user"
56
type
="org.springframework.web.struts.DelegatingActionProxy"
57
name
="userForm"
scope
="request"
parameter
="method"
58
validate
="false"
>
59
<
forward
name
="list"
path
="/userList.jsp"
/>
60
<
forward
name
="edit"
path
="/userForm.jsp"
/>
61
</
action
>
62
<
action
path
="/authors"
63
type
="org.apache.struts.actions.ForwardAction"
64
parameter
="/author.html"
/>
65
66
<
action
path
="/author"
67
type
="org.springframework.web.struts.DelegatingActionProxy"
68
name
="authorForm"
scope
="request"
parameter
="method"
>
69
<
forward
name
="list"
path
="/authorList.jsp"
/>
70
<
forward
name
="edit"
path
="/authorForm.jsp"
/>
71
</
action
>
72
73
<
action
path
="/categorys"
74
type
="org.apache.struts.actions.ForwardAction"
75
parameter
="/category.html"
/>
76
77
<
action
path
="/category"
78
type
="org.springframework.web.struts.DelegatingActionProxy"
79
name
="categoryForm"
scope
="request"
parameter
="method"
>
80
<
forward
name
="list"
path
="/categoryList.jsp"
/>
81
<
forward
name
="edit"
path
="/categoryForm.jsp"
/>
82
</
action
>
83
<
action
path
="/weblogs"
84
type
="org.apache.struts.actions.ForwardAction"
85
parameter
="/weblog.html"
/>
86
87
<
action
path
="/weblog"
88
type
="org.springframework.web.struts.DelegatingActionProxy"
89
name
="weblogForm"
scope
="request"
parameter
="method"
>
90
<
forward
name
="list"
path
="/weblogList.jsp"
/>
91
<
forward
name
="edit"
path
="/weblogForm.jsp"
/>
92
</
action
>
93
94
</
action-mappings
>
95
96
97
<!--
================================ Message Resources Definitions
-->
98
99
<
message-resources
parameter
="messages"
/>
100
101
<!--
======================================= Plug Ins Configuration
-->
102
103
<
plug-in
104
className
="org.springframework.web.struts.ContextLoaderPlugIn"
>
105
<
set-property
property
="contextConfigLocation"
106
value
="/WEB-INF/action-servlet.xml"
/>
107
</
plug-in
>
108
109
<
plug-in
className
="org.apache.struts.validator.ValidatorPlugIn"
>
110
<
set-property
property
="pathnames"
111
value
="/WEB-INF/validator-rules.xml,
112
/WEB-INF/validation.xml"
/>
113
</
plug-in
>
114
</
struts-config
>
validation.xml
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE form-validation PUBLIC
3
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN"
4
"http://jakarta.apache.org/commons/dtds/validator_1_1.dtd"
>
5
6
<
form-validation
>
7
<
formset
>
8
<
form
name
="userForm"
>
9
<
field
property
="user.lastName"
depends
="required"
>
10
<
arg0
key
="user.lastName"
/>
11
</
field
>
12
</
form
>
13
</
formset
>
14
</
form-validation
>
完整代码:
http://download.csdn.net/source/257866
posted on 2007-02-15 10:43
zhangjingqiang
阅读(563)
评论(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)