multisubmit.jsp
 1<%@ page pageEncoding="gb2312" contentType="text/html;charset=gb2312"%>
 2<%@ taglib prefix="ww" uri="webwork"%>
 3<html>
 4<head>
 5<title>MultiSubmit</title>
 6</head>
 7<body bgcolor="#FFFFFF">
 8
 9<ww:form name="msubmitform" action="'multisubmit'" method="POST">
10    <ww:submit name="'model.buttonOfPressed'" value="'ButtonOne'" ></ww:submit>
11    <ww:submit name="'model.buttonOfPressed'" value="'ButtonTwo'" ></ww:submit>
12    <ww:submit name="'model.buttonOfPressed'" value="'ButtonThree'" ></ww:submit>
13</ww:form>
14<ww:if test="text!=null" >
15    <ww:property value="text"/>
16</ww:if>
17</body>
18</html>
MultiSubmitBean.java
public class MultiSubmitBean {
    
private String text = "";

    
private String buttonOfPressed ="";

    
/**
     * @return Returns the buttonOfPressed.
     
*/

    
public String getButtonOfPressed() {
        
return buttonOfPressed;
    }

    
/**
     * @param buttonOfPressed The buttonOfPressed to set.
     
*/

    
public void setButtonOfPressed(String buttonOfPressed) {
        
this.buttonOfPressed = buttonOfPressed;
    }

    
/**
     * @return Returns the text.
     
*/

    
public String getText() {
        
return text;
    }


    
/**
     * @param text
     *            The text to set.
     
*/

    
public void setText(String text) {
        
this.text = text;
    }

}
MultiSubmitAction.java
 1public class MultiSubmitAction implements Action, ModelDriven {
 2
 3    MultiSubmitBean msb = new MultiSubmitBean();
 4
 5    /*
 6     * (non-Javadoc)
 7     * 
 8     * @see com.opensymphony.xwork.Action#execute()
 9     */

10    public String execute() throws Exception {
11        msb.setText(TextUtils.getGBString(msb.getButtonOfPressed()));
12        return SUCCESS;
13    }

14
15    /*
16     * (non-Javadoc)
17     * 
18     * @see com.opensymphony.xwork.ModelDriven#getModel()
19     */

20    public Object getModel() {
21        return msb;
22    }

23
24}

WebWork文档中的例子
<form action="MyAction.action">
<input type="submit" name="buttonOnePressed" value="First option">
<input type="submit" name="buttonTwoPressed" value="Alternative Option">
</form>
public class MyAction extends Action {

    /**
     * Action implementation
     *
     * Sets the message according to which button was pressed.
     **/
    public String execute() {
        if (buttonOnePressed) {
            message="You pressed the first button";
        } else if (buttonTwoPressed) {
            message="You pressed the second button";
        } else {
            return ERROR;
        }
        return SUCCES;
    }

    // Input parameters
    private boolean buttonOnePressed=false;
    private boolean buttonTwoPressed=false;

    public void setButtonOnePressed(boolean value) {
        this.buttonOnePressed = value;
    }


    public void setButtonTwoPressed(boolean value) {
        this.buttonTwoPressed = value;
    }

    // Output parameters

    private String message;
    public String getMessage() {
        return message;
    }
}
WebWork文档中的例子有问题(或许不适合ModelDriven模式)