当前位置: 代码迷 >> Java Web开发 >> sturts2 一个form 两个submit 交付不成功
  详细解决方案

sturts2 一个form 两个submit 交付不成功

热度:6675   发布时间:2013-02-25 21:14:45.0
sturts2 一个form 两个submit 提交不成功
sturts.xml
<action name="sendOrSaveToDraftBox" class="cn.itcast.oa.web.action.MessageAction" >
  <result type="redirectAction" name="outBox">outBox</result>
  <result type="redirectAction" name="draftBox">draftBox</result>
</action>

sendUI.jsp
<s:form action="sendOrSaveToDraftBox" method="post" namespace="/MessageAction" name="send">
  <s:select label="级别" name="priority" list="#{0:'普通',1:'重要'}" headerKey="-1" headerValue="请选择级别"/>
  <s:select label="收件人" name="receiverId" list="receiversList" multiple="true" listKey="id" listValue="name"/>
  <s:textfield label="标题" name="title" />
  <s:textarea label="消息内容" name="content" cols="50" rows="10" ></s:textarea>
  <s:submit value="发送" method="send"></s:submit>
  <s:submit value="保存草稿" method="saveToDraftBox"></s:submit>
  <s:reset></s:reset>
  </s:form>

class MessageAction extends ActionSupport{

//......

public String send() throws Exception {
//代码略

return "outBox";
}
public String saveToDraftBox() throws Exception {
//代码略

return "draftBox";
}
//......
}

严重: Could not find action or result
/ItcastOA4_resource_sms/MessageAction/sendOrSaveToDraftBox.action
No result defined for action cn.itcast.oa.web.action.MessageAction and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
  ......


为什么会这样呢,

------解决方案--------------------------------------------------------
将submit换成button 用JS来做跳转就行了!!!
------解决方案--------------------------------------------------------
<s:form action="sendOrSaveToDraftBox" method="post" namespace="/MessageAction" name="send">
namespace去掉,貌似楼主提交的路径不对
  相关解决方案