今天使用LookupDispatchAction时,由于编写的类继承LookupDispatchAction,同时也覆盖其execute()方法,结果导致自己编写的逻辑函数不起作用,把覆盖execute()方法的代码去掉即可实现同名按钮提交分别处理的效果,下面是代码:
<%
@ page contentType
=
"
text/html; charset=GBK
"
%>
<%
@ include file
=
"
taglib.jsp
"
%>
<
html
>
<
head
>
<
title
>
jsp7
</
title
>
</
head
>
<
body bgcolor
=
"
#ffffff
"
>
<
html:form action
=
"
/processCheckoutAction.do
"
>
<
html:text property
=
"
abc
"
>
</
html:text
>
<
html:submit property
=
"
action
"
><
bean:message
key
=
"
welcome.user
"
/></
html:submit
>
<
html:submit property
=
"
action
"
><
bean:message
key
=
"
goodbye.user
"
/></
html:submit
>
</
html:form
>
</
body
>
</
html
>
public
class
ProcessCheckoutAction
extends
LookupDispatchAction
...
{

protected Map getKeyMethodMap()...{
Map map=new HashMap();
map.put("welcome.user","saveorder");
map.put("goodbye.user","checkout");
return map;
}
public ActionForward saveorder(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,

HttpServletResponse response)...{
System.out.println("saveorder");
return (mapping.findForward("success1"));
}
public ActionForward checkout(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,

HttpServletResponse response)...{
System.out.println("checkout");
return (mapping.findForward("success2"));
}
}
<
action
name
="untitled2ActionForm"
parameter
="action"
path
="/processCheckoutAction"
scope
="request"
type
="test.ProcessCheckoutAction"
validate
="true"
>
<
forward
name
="success1"
path
="/jsp5.jsp"
/>
<
forward
name
="success2"
path
="/jsp6.jsp"
/>
</
action
>
JSP文件





















扩展的LookupDispatchAction




























Struts-config.xml相应的配置





