Spring3.0+Struts2.2+Hibernate3.6整合与常见问题
来源:互联网 发布:cisco 端口隔离 编辑:程序博客网 时间:2024/04/30 15:04
1
2
3
4
5
6
<
bean
id
=
"myDataSource"
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/mydb"
/>
<
property
name
=
"username"
value
=
"root"
/>
<
property
name
=
"password"
value
=
"3423"
/>
</
bean
>
1
2
3
4
5
6
7
8
9
10
<
bean
class
=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<
property
name
=
"locations"
value
=
"classpath:com/foo/jdbc.properties"
/>
</
bean
>
<
bean
id
=
"dataSource"
destroy-method
=
"close"
class
=
"org.apache.commons.dbcp.BasicDataSource"
>
<
property
name
=
"driverClassName"
value
=
"${jdbc.driverClassName}"
/>
<
property
name
=
"url"
value
=
"${jdbc.url}"
/>
<
property
name
=
"username"
value
=
"${jdbc.username}"
/>
<
property
name
=
"password"
value
=
"${jdbc.password}"
/>
</
bean
>
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
29
30
31
32
33
34
35
36
37
38
39
40
<
bean
id
=
"sessionFatory"
class
=
"org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
>
<
property
name
=
"dataSource"
ref
=
"dataSource"
/>
<!—当用annotation注解实体的时候,class必须为 *.hibernate3.annotation.AnnotationSessionFactoryBean -->
<
property
name
=
"annotatedClasses"
>
<
list
>
<
value
>com.bjsxt.model.User</
value
>
<
value
>com.bjsxt.model.Manager</
value
>
</
list
>
</
property
>
还有一种方法,这仅仅用于annotation中,扫描注定包中的实体类
<
property
name
=
"packagesToScan"
>
<
list
>
<
value
>com.bjsxt.model</
value
>
</
list
>
</
property
>
<!—当用hbm.xml的时候,class必须为*.hibernate3.LocalSessionFactoryBean -->
<
property
name
=
"mappingResources"
>
<
list
>
<
value
>product.hbm.xml</
value
>
</
list
>
</
property
>
<!—第一种指定值-->
<
property
name
=
"hibernateProperties"
>
<
props
>
<
prop
key
=
"hibernate.dialect"
>
org.hibernate.dialect.MySQLDialect</
prop
>
<
prop
key
=
"hibernate.show_sql"
>true</
prop
>
<
prop
key
=
"hibernate.format_sql"
>true</
prop
>
<
prop
key
=
"hibernate.hbm2ddl.auto"
>update</
prop
>
</
props
>
</
property
>
<!—第二种指定值-->
<
property
name
=
"hibernateProperties"
>
<
value
>
hibernate.dialect=org.hibernate.dialect.HSQLDialect
</
value
>
<
value
>hibernate.show_sql=true</
value
>
</
property
>
</
bean
>
1
2
3
<
bean
id
=
"hibernateTemplate"
class
=
"org.springframework.orm.hibernate3.HibernateTemplate"
>
<
property
name
=
"sessionFactory"
ref
=
"sessionFactory"
></
property
>
</
bean
>
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
29
30
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
web-app
id
=
"WebApp_9"
version
=
"2.4"
xmlns
=
"http://java.sun.com/xml/ns/j2ee"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!—设置监听器,使得应用程序启动就开始创建我们的beans-->
<
listener
>
<
listener-class
>org.springframework.web.context.ContextLoaderListener</
listener-class
>
</
listener
>
<!—配置应用程序加载的beans的路径-->
<
context-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>/WEB-INF/applicationContext-*.xml,classpath*:
applicationContext-*.xml</
param-value
>
</
context-param
>
<!—struts基本配置,主要是负责过滤url请求的-->
<
display-name
>Struts Blank</
display-name
>
<
filter
>
<
filter-name
>struts2</
filter-name
>
<
filter-class
>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</
filter-class
>
</
filter
>
<
filter-mapping
>
<
filter-name
>struts2</
filter-name
>
<
url-pattern
>/*</
url-pattern
>
</
filter-mapping
>
<
welcome-file-list
>
<
welcome-file
>index.html</
welcome-file
>
</
welcome-file-list
>
</
web-app
>
1
2
3
4
5
6
7
8
9
<
filter
>
<
filter-name
>openSessionInView</
filter-name
>
<
filter-class
>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</
filter-class
>
</
filter
>
<
filter-mapping
>
<
filter-name
>openSessionInView</
filter-name
>
<
url-pattern
>/*</
url-pattern
>
</
filter-mapping
>
1
2
3
4
5
6
7
8
9
10
11
12
13
<
filter
>
<
filter-name
>encodingFilter</
filter-name
>
<
filter-class
>
org.springframework.web.filter.CharacterEncodingFilter</
filter-class
>
<
init-param
>
<
param-name
>encoding</
param-name
>
<
param-value
>GBK</
param-value
>
</
init-param
>
</
filter
>
<
filter-mapping
>
<
filter-name
>encodingFilter</
filter-name
>
<
url-pattern
>/*</
url-pattern
>
</
filter-mapping
>
0 0
- Spring3.0+Struts2.2+Hibernate3.6整合与常见问题
- Struts2.2+Spring3.0+Hibernate3.6整合
- 第五章 Spring3.0 、Hibernate3.3与Struts2的整合
- struts2 spring3 hibernate3整合
- Struts2+Spring3+Hibernate3整合
- Struts2+Hibernate3+Spring3 整合
- Struts2+Spring3+Hibernate3整合
- spring3 struts2 hibernate3整合
- spring3.0+hibernate3.6+struts2.2.3整合过程
- Struts2.0+Hibernate3.0+Spring3.2整合实例
- 整合Struts2.1+Hibernate3.3+Spring3.0
- spring3.0 + hibernate3.5 + struts2的整合
- 毕业设计(二)---struts2 hibernate3 spring3.0 整合
- 基于MyEclipse8.6开发Spring3.0+Hibernate3.3+Struts2.2整合笔记一
- struts2+spring3+hibernate3整合步骤
- struts2+hibernate3+spring3整合步骤
- Struts2-Spring3-Hibernate3整合开发
- spring3.2MVC与hibernate3整合配置文件
- linux设置dhcp中继代理
- Android view利用canvas绘制动画(一)
- 【1】依照Django官网,编写一个web app 创建工程/配置数据库
- Android 开源项目分类汇总
- JStorm中消息确保处理机制
- Spring3.0+Struts2.2+Hibernate3.6整合与常见问题
- 负载均衡方案总结
- Android Studio导入第三方类库的方法
- c中字符串分割函数strtok
- [Elasticsearch] 数据建模 - 处理关联关系(1)
- libevent源代码分析-介绍、安装、使用
- 数据结构 字符串二分查找正确实现
- bzoj 1047
- 避免进度调整失误