javajqueryjspstruts2struts2-jquery

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?


Solution

  • 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>