【问题标题】:Struts 2 - Submit button onclick trigger issueStruts 2 - 提交按钮 onclick 触发问题
【发布时间】:2013-07-02 17:51:01
【问题描述】:

我在表单中有一个 Struts <s:submit> 按钮,当我单击该按钮时,页面应该保持不变,所以我在提交按钮中添加了一个 onclick 函数:

<s:submit action="product" method="loadsearch" id="find" onclick="return false"/>

为什么提交按钮没有触发提交?

【问题讨论】:

    标签: java jquery jsp struts2 struts2-jquery


    【解决方案1】:

    要在同一页面上需要进行 Ajax 调用,就您使用 struts2-jquery 插件而言,很容易通过

    将它放在 JSP 上

    <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> 
    <head>
     <sj:head/>
    </head>
    
    <s:div id="result"/>
    
    <s:form action="product" method="POST"/>
      <sj:submit method="loadsearch" id="find" targets="result" />
    </s:form>
    

    【讨论】:

      【解决方案2】:

      因为你return false取消了提交。

      【讨论】:

      • 好的,我想提交表单但它不应该转发到另一个页面,那么我必须使用ajax调用或struts2-jquery提交按钮?
      猜你喜欢
      • 1970-01-01
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多