简体   繁体   中英

Struts 2 - Submit button onclick trigger issue

I have a Struts <s:submit> button in the form and when I click the button, the page should remain the same, so I added an onclick function to the submit button:

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

Why is the submit button not triggering a submit?

因为您return false会取消提交。

To be on the same page needs to make Ajax call, as far as you using struts2-jquery plugin it's easy done via

place it on the 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM