10分鐘學(xué)懂Struts 2.0 攔截器
Struts 2.0攔截器
簡(jiǎn)介 |
在Struts 2.0 中的攔截器,要實(shí)現(xiàn)com.opensymphony.xwork2.interceptor.Interceptor接口,在struts.xml中配置。可以用攔截器來完成調(diào)用Action業(yè)務(wù)邏輯之前的預(yù)處理或是之后的善后處理。還可以通過配置多個(gè)攔截器來滿足action需求。
Interceptor stack是由多個(gè)攔截器組成的攔截器組,在攔截器組中可以對(duì)每一個(gè)攔截器映射。所有進(jìn)行配置攔截器時(shí),不必對(duì)每一個(gè)攔截器進(jìn)行配置,而只需對(duì)interceptor stack進(jìn)行配置即可。在struts 2中默認(rèn)配置了一個(gè)全局interceptor stack,包括Exception Interceptor、Validation Interceptor等。
實(shí)例 |
在這個(gè)實(shí)例當(dāng)中,我將配置一個(gè)時(shí)間攔截器,用來統(tǒng)計(jì)每個(gè)action的請(qǐng)求時(shí)間。













































interceptordemo.jsp:







posted on 2009-05-08 20:31 fun 閱讀(1520) 評(píng)論(0) 編輯 收藏