Struts中的Action類的工作機(jī)制
所有的Action類都是org.apache.struts.action.Action的子類。Action子類應(yīng)該覆寫父類的execute()方
法。當(dāng)ActionForm
Bean被創(chuàng)建,并且表單驗(yàn)證順利通過后,Struts框架就會調(diào)用Action類的execute()方法。execute()方法的定義如下:
public ActionForward execute(ActionMapping mapping
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException;
execute()方法包含一下參數(shù):
· ActionMapping:包含了這個Action的配置信息,和struts-config.xml文件中的
<action>元素對應(yīng)。
· ActionForm:包含了用戶的表單數(shù)據(jù),當(dāng)Struts框架調(diào)用execute()方法時,
ActionForm中的數(shù)據(jù)已經(jīng)通過了表單驗(yàn)證。
· HttpServletRequest:當(dāng)前的HTTP請求對象。
· HttpServletResponse:當(dāng)前的HTTP響應(yīng)對象。
Action類的execute()方法返回ActionForward對象,它包含了請求轉(zhuǎn)發(fā)路徑信息。
2005年03月31日 1:30 AM