雖然LookupDispatchAction類可以很好地處理擁有多個提交按鈕的Form
我們可以按如下三步來使用EventDispatchAction類
【第
在<samples工程目錄>\src\action目錄中建立一個MyEventDispatchAction
package action;
import java
import javax
import org
import org
public class MyEventDispatchAction extends EventDispatchAction
{
// 處理print動作
public ActionForward print(ActionMapping mapping
HttpServletRequest request
{
try
{
response
PrintWriter out = response
out
}
catch (Exception e)
{
}
return null;
}
// 處理save動作
public ActionForward save(ActionMapping mapping
HttpServletRequest request
{
try
{
response
PrintWriter out = response
out
}
catch (Exception e)
{
}
return null;
}
}
在MyEventDispatchAction類中有兩個方法
【第
打開struts
<action name =
type=
【第
在Web根目錄中建立一個moreSubmit
<%@ page pageEncoding=
<%@ taglib uri=
<html>
<head>
<title>多提交演示</title>
</head>
<body>
<html:form action=
name
<html:submit property=
<html:submit property=
</html:form>
</body>
</html>
在編寫moreSubmit
啟動Tomcat後
為了區別提交請求參數和其他參數
<html:submit property=
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28126.html