ssh整合源码一:配置Spring之applicationContext.xml和web.xml
来源:互联网 发布:淘宝 老王代写 编辑:程序博客网 时间:2024/05/22 04:33
ssh整合源码一:配置Spring之applicationContext.xml和web.xml
Spring1.applicationContext.xml
基本内容:
1. 配置数据库连接池
2. 配置Hibernate(sessionFactory和事务)
3. 装配3个bean(相当于struts2)——手动装配
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version=
"1.0"
encoding=
"UTF-8"
?>
<beans xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xsi:schemaLocation="http:
//www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http:
//www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http:
//www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http:
//www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<context:property-placeholder location=
"classpath:jdbc.properties"
/>
<bean id=
"dataSource"
class
=
"com.mchange.v2.c3p0.ComboPooledDataSource"
>
<property name=
"user"
value=
"${user}"
></property>
<property name=
"password"
value=
"${password}"
></property>
<property name=
"jdbcUrl"
value=
"${url}"
></property>
<property name=
"driverClass"
value=
"${driver}"
></property>
</bean>
<!-- 整合 Hibernate -->
<bean id=
"sessionFactory"
class
=
"org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
<property name=
"dataSource"
ref=
"dataSource"
></property>
<property name=
"configLocation"
value=
"classpath:hibernate.cfg.xml"
></property>
</bean>
<bean id=
"transactionManager"
class
=
"org.springframework.orm.hibernate3.HibernateTransactionManager"
>
<property name=
"sessionFactory"
ref=
"sessionFactory"
></property>
</bean>
<tx:advice transaction-manager=
"transactionManager"
id=
"txAdvice"
>
<tx:attributes>
<tx:method name=
"get*"
read-only=
"true"
/>
<tx:method name=
"*"
/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression=
"execution(* net.lampbrother.ssh.*ServiceImpl.*(..))"
id=
"txPointcut"
/>
<aop:advisor advice-ref=
"txAdvice"
pointcut-ref=
"txPointcut"
/>
</aop:config>
<bean id=
"customerDao"
class
=
"net.lampbrother.ssh.CustomerDao"
>
<property name=
"sessionFactory"
ref=
"sessionFactory"
/>
</bean>
<bean id=
"customerService"
class
=
"net.lampbrother.ssh.CustomerServiceImpl"
>
<property name=
"customerDao"
ref=
"customerDao"
></property>
</bean>
<bean id=
"cusotmerAction"
class
=
"net.lampbrother.ssh.CusotmerAction"
>
<property name=
"customerService"
ref=
"customerService"
></property>
</bean>
</beans>
Spring2.
web.xml
主要内容:
1.配置struts2
2.配置spring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version=
"1.0"
encoding=
"UTF-8"
?>
<web-app xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:web=
"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id=
"WebApp_ID"
version=
"2.5"
>
<!-- 配置Struts2 -->
<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>
<!-- 配置Spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-
class
>org.springframework.web.context.ContextLoaderListener</listener-
class
>
</listener>
</web-app>
0 0
- ssh整合源码一:配置Spring之applicationContext.xml和web.xml
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- spring+hibernate整合web.xml、applicationContext.xml配置
- spring+hibernate整合web.xml、applicationContext.xml配置
- SSH整合配置applicationContext.xml/hibernate.cfg.xml/struts.xml
- spring web.xml applicationContext.xml常见配置
- spring源码解析之默认配置文件名/WEB-INF/applicationContext.xml
- spring整合struts2之web.xml配置
- SSH框架整合中:spring在web.xml中的配置
- SSH中 applicationcontext.xml与web.xml的配置
- spring整合hibernate(注解、xml)applicationContext.xml配置
- spring整合hibernate(注解、xml)applicationContext.xml配置
- spring整合hibernate(注解、xml)applicationContext.xml配置
- spring整合hibernate(注解、xml)applicationContext.xml配置
- spring整合hibernate(注解、xml)applicationContext.xml配置
- SSH整合-关于Spring中applicationContext.xml文件对于事务的一些配置
- springMVC之web.xml,spring-mvc.xml与applicationContext.xml
- spring applicationContext.xml配置
- UVa 11646 Athletics Track(几何)
- 练习打印杨辉三角形
- html页面在IOS-safari浏览器下绑定点击绑定事件的div时会显示灰色框的问题
- 坐在马桶上学算法@最常用的排序——快速排序
- Linux安装mysql——源码安装
- ssh整合源码一:配置Spring之applicationContext.xml和web.xml
- 装饰者模式及C++代码实现
- Android Permission大全(中文说明)
- js 动态为textbox添加下拉框数据源
- 中间件websphere集群环境JDBC的保存位置
- window平台搭建Hudson服务器
- Window下安装Libnet环境时候遇到的问题:找不到'Pcap.h'和'未定义ip-nh'
- Intent学习笔记整理
- spring+hibernate整合web.xml、applicationContext.xml配置