鐪嬪埌 Shale 鐨?Spring Integration 鏂囨。鐨勪粙緇嶅師鐞嗭紝鍏朵腑欏哄簭濡備笅錛?/font>
When asked to resolve a variable name, the following algorithm is performed:
1.Does a bean with the specified name already exist in some scope (request, session, application)? If so, return it.
2.Is there a standard JavaServer Faces managed bean definition for this variable name? If so, invoke it in the usual way, and return the bean that was created.
3.Is there configuration information for this variable name in the Spring WebApplicationContext for this application? If so, use it to create and configure an instance, and return that instance to the caller.
4.If there is no managed bean or Spring definition for this variable name, return null instead.
榪欐牱鐨勮瘽錛屽彧瑕?Spring 鍙互鎺у埗 Bean 鐨?Scope 鐨勮瘽錛屽氨鍙互鎶?Managed-Bean 鐨勯厤緗斁鍒?Spring Bean 閲屾潵閰嶇疆錛屼竴鏂歸潰錛屾垜浠彲浠ョ渷鍘諱簡(jiǎn) JSF 鐨?Managed Bean 鐨勯厤緗紝鍙﹀鐨勮瘽錛屾垜浠彲浠ュ JSF 鐨?Backing Bean 浣跨敤 AOP 浠ュ強(qiáng) Spring 鎻愪緵鐨勫緢澶氬姛鑳姐傝繃鍘誨湪 JSF-Spring 涓皾璇曠潃鍘繪帶鍒?Spring Bean 鐨?Scope錛屼絾鏄仛鐨勫茍涓嶅ソ錛岀幇鍦?Spring 2.0 緇欐垜浠彁渚涗簡(jiǎn)榪欐牱鐨勮兘鍔涳紝緇忚繃瀹為獙錛岃瘉鏄庝簡(jiǎn)榪欐牱鏄彲琛岀殑銆?/font>
涓嶈繃濡傛灉浣跨敤 Spring Bean 浠ュ悗錛屼細(xì)閫犳垚浣跨敤 Managed Bean 鐨?JSTL 鏃犳硶浣跨敤錛屽叾瀹?JSTL 鏈韓鐢ㄨ搗鏉ュ氨鏃跺ソ鏃跺潖鐨勶紝鎵浠ュ獎(jiǎng)鍝嶅茍涓嶅お澶т簡(jiǎn)銆?/font>
鏁村悎璧鋒潵姝ラ闈炲父鐨勭畝鍗曪細(xì)
1. 鎶?Spring 2.0 鐨?jar 鏂囦歡鏀懼埌 lib 涓嬮潰錛屽綋鍓嶄嬌鐢ㄧ殑鏄?Spring 2.0 RC3
2. 鍥犱負(fù)浣跨敤鐨勬槸 Servlet 2.4錛屾墍浠ヨ鍦?web.xml 涓姞鍏?br />
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
3. 淇敼 applicationContext.xml
娉ㄩ噴鎴栧垹鎺変互涓嬪唴瀹癸細(xì)
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
" http://www.springframework.org/dtd/spring-beans.dtd ">
淇敼 <beans> 涓猴細(xì)
<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 "
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.xsd ">
4. 鐒跺悗灝卞彲浠ユ寜鐓ч厤緗?Spring Bean 鐨勬柟寮忔潵閰嶇疆 Managed Bean:
榪欎釜鏄?Request Scope 涓殑 Bean:
<bean id="loginBean" class="org.agilejava.icustomer.backingbean.LoginBean"
scope="request" autowire="byName">
<aop:scoped-proxy/>
</bean>
榪欎釜鏄?Session Scope 涓殑 Bean:
<bean id="menuBean" class="org.agilejava.framework.commons.menu.MenuBackingBean"
scope="session" autowire="byName">
<aop:scoped-proxy/>
</bean>
铏界劧鐭湡鏉ョ湅錛岄厤緗笂浼?xì)灏戝啓浜?jiǎn)涓浜涳紝鍥犱負(fù) autowire="byName"錛屼絾鏄粠闀胯繙鏉ョ湅錛屾垜浠彲浠ュ埄鐢?Spring 鐨勬洿澶氬姛鑳斤紝姣斿 AOP 鏉ュ寮?Backing Bean 鐨勮兘鍔涳紝鎴戠殑絎竴涓鎯沖氨鏄敤 AOP 鏉ュ鐞?Backing Bean 涓殑寮傚父.good