form.submit与方法之间有所不同

时间:2013-07-12 07:53:46

标签: javascript struts2 submit

我正在处理一些代码:

verify_scan_image_main.jsp

......

<s:form id="scanImageReportFrom" action="" method="post">
    ......
    <tr>

        <td align="left" width="12%">
            <s:submit type="button" label="Find" onclick="return goFind();" 
                    method="verifyScanImage" style="width:60px" theme="simple" />
        </td>
    </tr>
</s:form>

<script language="JavaScript">
function goFind()
{
    ......

    scanImageReportFrom.action = 'scanimagereport/verifyScanImage.action';
    scanImageReportFrom.submit();
    return false;
}
</script>

struts.xml

<struts>
    ......

    <package name="scanimagereport" extends="struts-default">
        ......

        <action name="verifyScanImage"
               class="hk.net.scanimagereport.action.VerifyScanImageAction" 
               method="verifyScanImage">
            <result name="success">/verify_scan_image_main.jsp</result>
            <result name="input">/verify_scan_image_main.jsp</result>
        </action>       
    </package>
</struts>

在上面的代码中,如果我按如下方式更改goFind()函数,结果不一样。我不明白为什么。

<script language="JavaScript">
  function goFind()
  {
     ......

     //scanImageReportFrom.action = 'scanimagereport/verifyScanImage.action';
     //scanImageReportFrom.submit();
     //return false;
     return true;
  }
</script>

1 个答案:

答案 0 :(得分:0)

您应该在点击时处理onsubmit事件,否则它将根据您的操作属性""提交到操作verifyScanImage