在filter中獲取action的引數值

2022-02-01 04:33:34 字數 528 閱讀 2888

public voidonactionexecuting(actionexecutingcontextfiltercontext)

中比較方便

有filtercontext.actionparameters,key:value,直接可以獲得

但是在其他的

public void onactionexecuted(actionexecutedcontext filtercontext)
public void onauthorization(authorizationcontext filtercontext)
等等這些引數沒有提供actionparameters

filtercontext.actiondescriptor.getparameters()通過actiondescriptor可以獲得引數名,但是無法獲得引數值

引數值可以通過

filtercontext.controller.valueprovider.getvalue(「??」)

來獲得,也不知道這東西效能怎麼樣

在filter中獲取Spring容器中的bean

有時會有這樣的需要,在filter中獲取spring的bean,這時使用 autowired註解去自動注入bean就會出現空指標異常,為什麼會這樣呢?component override throws bean ception 根據name public static object getbean ...

filter只過濾jsp不過濾action解決方法

修改在web.xml中的配置,將過濾的配置放到struts前面,如下 checkloginfilter com.alpha.web.filter.checkloginfilter 檢查失敗後需要定向到的頁面 redirecturl login login.jsp 不用檢查使用者的頁面列表,用 分隔 ...

獲取所有Controller和Action

def require all controllers path dir.new path entries.collect do e controller path file.join path,e ife 0 46 require all controllers將載入指定目錄下的所有以contro...