CSDN博客

img Arqui

使用LookupDispatchAction

发表于2004/10/10 13:20:00  1545人阅读

使用LookupDispatchAction
1、JSP中如此定义,property一定要一样

          <html:submit property="action" >
                <bean:message key="admin.jsp.prompt.check"/></html:submit>
      
          <html:submit property="action" >
                <bean:message key="admin.jsp.prompt.update"/></html:submit>

2、建立一个beanform(做按钮的选择)

private String action;
 
 public String getAction(){
  return action;
 }
 public void setAction(String action){
  this.action=action;
 }

3、响应的action
public class BeanAction extends LookupDispatchAction{
 protected Map getKeyMethodMap(){
   Map map= new HashMap();
   map.put("admin.jsp.prompt.check","check");
   map.put("admin.jsp.prompt.update","ok");
   return map;
  }
  public ActionForward check(ActionMapping parm1,ActionForm form,
  HttpServletRequest parm3,HttpServletResponse parm4) throws
  IOException,ServletException{
  BeanForm bean=(BeanForm)form;
  return parm1.findForward("check");
  }
     public ActionForward update(ActionMapping parm1,ActionForm form,
     HttpServletRequest parm3,HttpServletResponse parm4) throws
     IOException,ServletException{
  BeanForm bean=(BeanForm)form;
  return parm1.findForward("update");
  }

4、在struts-config中mapping
<action
            attribute="beanForm"
            input="/jsp/admin.jsp"
            name="beanForm"
            parameter="action"
            path="/beanAction"
            type="eg.jl.message.action.BeanAction"
            validate="false">
            <forward name="add" path="/check.do" />
            <forward name="update" path="/updatedo" />
</action>

阅读全文
0 0

相关文章推荐

img
取 消
img