---------------------------------------------------------------------- RequestContextListener and RequestContextFilter 涓や釜綾誨仛鐨勯兘鏄悓鏍風殑宸ヤ綔錛涘皢HTTP request 瀵硅薄緇戝畾鍒頒負璇ヨ姹傛彁渚涙湇鍔$殑Thread銆傝繖浣垮叿鏈塺equest or session 浣滅敤鍩熺殑bean鑳藉鍦ㄥ悗闈㈢殑璋冪敤閾句腑琚闂埌銆?br />
浣滅敤鍩焍ean 涓庝緷璧?br />濡傛灉鎵撶畻灝嗕竴涓狧ttp request 鑼冨洿鐨刡ean 娉ㄥ叆鍒板埆涓涓猙ean 涓紝閭d箞闇瑕佹敞鍏ヤ竴涓狝OP浠g悊鏉ユ浛浠h娉ㄥ叆鐨勪綔鐢ㄥ煙bean錛屼篃灝辨槸璇撮渶瑕佹敞鍏ヤ竴涓唬鐞嗗璞°?br />娉ㄦ剰 <aop:scoped-proxy/>涓嶈兘鍜屼綔鐢ㄥ煙涓簊ingleton 鎴?prototype 鐨刡ean涓璧蜂嬌鐢ㄣ?br /> <?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" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- a HTTP Session-scoped bean exposed as a proxy --> <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"> <!-- this next element effects the proxying of the surrounding bean --> <aop:scoped-proxy/> </bean> <!-- a singleton-scoped bean injected with a proxy to the above bean --> <bean id="userService" class="com.foo.SimpleUserService"> <!-- a reference to the proxied 'userPreferences' bean --> <property name="userPreferences" ref="userPreferences"/> </bean>