<!--[if !supportLineBreakNewLine]-->
" method="post">

<input type="submit" value="保存" />
<input type="submit" value="打印" />
</html>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>My JSP 'hello.jsp' starting page</title>
</head>
<body>
<s:form action="submit.action" >
<s:textfield name="msg" label="输入内容"/>
<s:submit name="save" value="保存" align="left" method="save"/>
<s:submit name="print" value="打印" align="left" method="print" />
</s:form>
</body>
</html>
import javax.servlet.http.*;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.*;
public class MoreSubmitAction extends ActionSupport implements ServletRequestAware
{
private String msg;
private javax.servlet.http.HttpServletRequest request;
// 获得HttpServletRequest对象
public void setServletRequest(HttpServletRequest request)
{
this.request = request;
}
// 处理save submit按钮的动作
public String save() throws Exception
{
request.setAttribute("result", "成功保存[" + msg + "]");
return "save";
}
// 处理print submit按钮的动作
public String print() throws Exception
{
request.setAttribute("result", "成功打印[" + msg + "]");
return "print";
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
}
org.apache.struts2.interceptor. ServletRequestAware
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="demo" extends="struts-default" >
<action name="submit" class="action.MoreSubmitAction">
<result name="save" >
/result.jsp
</result>
<result name="print">
/result.jsp
</result>
</action>
</package>
</struts>
<html>
<head>
<title>提交结果</title>
</head>
<body>
<h1>${result}</h1>
</body>
</html>
http://localhost:8080/moresubmit/more_submit.jsp
调用save方法:http://localhost:8080/moresubmit/submit!save.action
















