Struts中的Action类的工作机制

- 中国WEB开发者网络 (http://www.webasp.net)
-- 技术教程 (http://www.webasp.net/article/)
--- Struts中的Action类的工作机制 (http://www.webasp.net/article/22/21773.htm)
-- 作者:未知
-- 发布日期: 2005-04-30
Struts中的Action类的工作机制  所有的Action类都是org.apache.struts.action.Action的子类。Action子类应该覆写父类的execute()方法。当ActionForm Bean被创建,并且表单验证顺利通过后,Struts框架就会调用Action类的execute()方法。execute()方法的定义如下:    public ActionForward execute(ActionMapping mapping                        ActionForm form,                        HttpServletRequest request,                        HttpServletResponse response) throws IOException, ServletException;    execute()方法包含一下参数:  · ActionMapping:包含了这个Action的配置信息,和struts-config.xml文件中的     <action>元素对应。  · ActionForm:包含了用户的表单数据,当Struts框架调用execute()方法时,     ActionForm中的数据已经通过了表单验证。  · HttpServletRequest:当前的HTTP请求对象。  · HttpServletResponse:当前的HTTP响应对象。  Action类的execute()方法返回ActionForward对象,它包含了请求转发路径信息。

webasp.net