07-11
12

在Action中定义多个方法及其使用

在Action中定义多个方法及其使用

1 Action类要继承DispatchAction类;

2 不能有"execute()"在此类中出现,因为execute()会被默认调用;

3 方法的定义形式要如下

public void hello(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse respons){
  System.out.println("===say hello===>>>");
}
*其中参数ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse respons是必需的

4 在struts-config.xml中设置Action时要加上parameter="method",如下
<action      
       name="addMemberForm"
       path="/addMember"
       parameter="method"
       scope="request">

5 使用时
  <html:link page="/addMember.do?method=hello">hello</html:link>
  在Action类也可以使用

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: Action
相关日志:
评论: 1 | 引用: 0 | 查看次数: 851
回复回复1[2007-12-21 04:13 PM | del]
不够详细啊
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭