配置處理結果---struts2學習筆記

<action name="login" class="lee.LoginAction">

<result name="success"  type="dispatcher">                       //type結果類型有chain,dispatcher,redirect..等

<param name="location">/thank.jsp</param>             //視圖資源

<param name="charset">GBK</param>                      //編碼方式

</result>

</action>


重點:Action屬性值決定物理視圖資源

<action name="save" class="lee.LoginAction">

<result type="redirect">edit.action?skillName=${currentSkill.name}</result>               //使用OGNL表達式來指定視圖資源

</action>


對於上面的表達式語法,在對應的Action實例裏應該包含currentSkill屬性,且currentSkill必須包含name屬性,否則表達式的值爲null



使用PreResultListener可以在Action完成控制處理後,系統轉入實際的物理視圖之前被回調

例:

ActionInvocation in = ActionContext.getContext().getActionInvocation();

in.addPreResultListener(new PreResultListener(){

//重寫方法beforeResult

}

)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章