生命在于運(yùn)動

          2008年1月8日 #

          3.2. Filters 過濾器 (to be modified)

            3.2. Filters            
                        過濾器
           

          Acegi Security 使用很多種過濾器,過濾器的內(nèi)容將會貫穿本參考文檔的剩余部分。你可以選擇怎么樣在你的web應(yīng)用程序中使用這些過濾器,你可以使用FilterToBeanProxy或者FilterChainProxy。下面我們就會討論這兩個過濾器。

          大多數(shù)過濾器都是使用FilterToBeanProxy配置,下面是一個web.xml中配置的例子:

          <filter>

          <filter-name>Acegi HTTP Request Security Filter</filter-name>

          <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>

          <init-param>

          <param-name>targetClass</param-name>

          <param-value>org.acegisecurity.ClassThatImplementsFilter</param-value>

          </init-param>

          </filter>

          請注意,在web.xml中配置的過濾器實(shí)際上就是FilterToBeanProxy,而不是真正實(shí)現(xiàn)該過濾器邏輯的。FilterToBeanProxy的工作就是將過濾器的方法代理給一個bean,而這個bean能夠從Spring應(yīng)用的上下文中取到。這個將能夠使bean享受到Spring應(yīng)用程序上下文的生命周期的支持和配置的靈活性。當(dāng)然該bean是必須要要實(shí)現(xiàn)javax.servlet.Filter的。FilterToBeanProxy僅僅需要一個簡單的初始化參數(shù),targetClass或者targetBean。targetClass是用來定位在應(yīng)用程序上下文中第一個對象的指定類,而targetBean則是通過bean name來定位對象的。就好像標(biāo)準(zhǔn)的Spring web應(yīng)用程序FilterToBeanProxy能夠通過WebApplicationContextUtils.getWebApplicationContext(ServletContext)訪問應(yīng)用程序上下文,所以你該在web.xml中定義一個ContextLoaderListener。

          posted @ 2008-01-10 17:35 burrows 閱讀(233) | 評論 (0)編輯 收藏

          Chapter 3. Supporting Infrastructure (todo)

               摘要:   閱讀全文

          posted @ 2008-01-10 17:33 burrows 閱讀(246) | 評論 (0)編輯 收藏

          Spring組件發(fā)布包

               摘要:   閱讀全文

          posted @ 2008-01-08 09:33 burrows 閱讀(408) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 诸暨市| 新巴尔虎左旗| 连平县| 乌兰察布市| 福贡县| 泸溪县| 红安县| 华坪县| 昌黎县| 信阳市| 文登市| 弥渡县| 邻水| 龙州县| 师宗县| 瓮安县| 贵州省| 西平县| 盐山县| 嘉义市| 苍溪县| 南城县| 来安县| 牙克石市| 读书| 滕州市| 略阳县| 婺源县| 广汉市| 乌拉特前旗| 宜宾市| 平乡县| 安康市| 多伦县| 阳新县| 德阳市| 府谷县| 荥经县| 增城市| 焦作市| 仁化县|