你可以調用不同的操作方法,在你的行動,不僅是 「執行」 的方法。只需在請求中添加名爲「method:actionMethodName」的參數即可。下面是例子:
public class MyAction extends ActionSupport {
public String execute() {
// Base code
return SUCCESS;
}
public String one() {
// Code one
return SUCCESS;
}
public String two() {
// Code two
return SUCCESS;
}
}
而這裏的jsp:
<s:form action="MyAction">
<input type="submit" value="Call execute"/>
<input type="submit" name="method:one" value="Call method one"/>
<input type="submit" name="method:two" value="Call method two"/>
</s:>
或者你也可以做這樣的:
<s:form action="MyAction" name="form0">
<!-- call execute-->
</s:>
<s:form action="MyAction" name="form1">
<!-- call method one-->
<input type="hidden" name="method:one"/>
</s:>
<s:form action="MyAction" name="form2">
<!-- call method two-->
<input type="hidden" name="method:two"/>
</s:>
「發現哪個表單提交」 - 你的電話一個動作從不同的形式,並知道至少提交了一些不同的邏輯在行動? –