首先將
spring
加入到web容器在
web.xml
中加入<
context-param
>
<
param-name
>
contextconfiglocation
param-name
> (
說明:為了管理方便設定了多個
spring
的配置檔案 、
、context-param
>
然後加入
spring
***:
<
listener
>
<
listener-class
>
org.springframework.web.context.contextloaderlistener
listener-class
>
listener
>
接下來spring
與struts
整合spring
的配置檔案中的
bean
:<
bean
name
="/today"
class
="com.adcc.inves.web.action.today.todayaction"
scope
="prototype"
>
<
property
name
="todaymanager"
ref=
"todaymanager"
>
property
>
<
property
name
="envroutemanager"
ref=
"envroutemanager"
>
property
>
<
property
name
="fmeflightstodayservice"
ref=
"fmeflightstodayservice"
>
property
>
<
property
name
="invesairportmanager"
ref=
"invesairportmanager"
>
property
>
bean
>
然後我們配置
struts.xml
中的action
就要這樣配:
<
action
path
="/today"
type
="org.springframework.web.struts.delegatingactionproxy"
name
="todayform"
scope
="request"
parameter
="method"
>
<
forward
name
="allairporttomorrowplan"
path
="/jsp/common/tomorrowcontainer.jsp"
>
forward
>
<
forward
name
="allairportstatistics"
path
="/jsp/common/statisticscontainer.jsp"
>
forward
>
action
>
接下來整合
spring
與hibernate。將
hibernate
交由spring
管理:在
spring
配置檔案
中加入
<
bean id=
"sessionfactory"
class
="org.springframework.orm.hibernate3.localsessionfactorybean"
>
<
property
name
="configlocation"
>
<
value
>
classpath:hibernate.cfg.xml
value
>
property
>
bean
>
<
bean id=
"transactionmanager"
class
="org.springframework.orm.hibernate3.hibernatetransactionmanager"
>
<
property
name
="sessionfactory"
>
<
ref
local
="sessionfactory"
/>
property
>
bean
>
<
tx:advice id=
"txadvice"
transaction-manager
="transactionmanager"
>
<
tx:attributes
>
<
tx:method
name
="*"
propagation
="required"
/>
<
tx:method
name
="modify*"
isolation
="default"
propagation
="required"
read-only
="false"
/>
tx:attributes
>
tx:advice
>
<
aop:config
>
<
aop:pointcut id=
"modifycapicity"
expression
="execution(* com.adcc.inves.manager.*.*.*(..))"
/>
<
aop:advisor
advice-ref
="txadvice"
pointcut-ref
="modifycapicity"
/>
aop:config
> 在
web.xml
中加入: 1、
spring
關閉session
<
filter
>
<
filter-name
>
hibernatefilter
filter-name
>
<
filter-class
>
org.springframework.orm.hibernate3.support.opensessioninviewfilter
filter-class
>
filter
>
<
>
<
filter-name
>
hibernatefilter
filter-name
>
<
url-pattern
>
/*url-pattern
>
> 2、
spring
處理字元編碼
<
filter
>
<
filter-name
>
spring character encoding filter
filter-name
>
<
filter-class
>
org.springframework.web.filter.characterencodingfilter
filter-class
>
<
init-param
>
<
param-name
>
encoding
param-name
>
<
param-value
>
utf-8
param-value
>
init-param
>
filter
>
<
>
<
filter-name
>
spring character encoding filter
filter-name
>
<
url-pattern
>
/*url-pattern
>
>
SSH框架整合
版本 struts 2.3.30,spring framework 3.2.10.release,hibernate distribution 3.6.0.final 一 引入相關jar檔案 二 struts.xml配置 apache software foundation dtd struts c...
SSH框架整合
記事本手打 正確率略低 1.匯入jar包 name cn.com.product table product name pid column pid class native id name pname column pname property name page column page prop...
SSH框架整合
用的是 myeclipse7.5,spring2.5,hibernate3.2,struts2.0 第一步 新增spring 能力 至少要匯入四個spring 庫 1 spring 2.5 core libraries 2 spring 2.5 persistence core libraries ...