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模式)