Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It can be easily done by <strong>changing the form action</strong>, in the JSP Page..</p> <blockquote> <p>You can use <strong>JavaScript to change the action name</strong>. By doing that you can map the jsp to another class using struts.XML. All you need is a new action definition in the <strong>Struts.XMl.</strong> </p> <p>In the bean class, you just want create a variable with the name of your list and of the same type, and finally create Getters and setters. You will be getting all the values in the jsp, (<strong><em>irrespective of the type</em></strong>) inside the bean(struts maps the values for you).</p> </blockquote> <p>Since you have said that you already got the list in one action. I am not getting in to that part.</p> <p><strong>Now here is how you can redirect the bean class(Action) from JSP.</strong></p> <p><strong>Jsp File</strong></p> <pre><code> &lt;s:form id="formid" action="action1"&gt; /.../ &lt;s:hidden name="lstVariablename"/&gt; &lt;s:hidden name="lstVariablename"/&gt; &lt;s:hidden name="lstVariablename"/&gt; &lt;s:hidden name="lstVariablename"/&gt; /.../ &lt;/s:form&gt; </code></pre> <p>Now create a JavaScript function inside the JSP</p> <pre><code>&lt;script&gt; function changeAction(){ document.formid.action =action2 } &lt;/script&gt; </code></pre> <p><strong>struts.XML</strong></p> <pre><code> &lt;action name="action1" class="com.XXX.Action1" method="methodOfAction1"&gt; &lt;result name="success"&gt;/name.jsp&lt;/result&gt; &lt;/action&gt; &lt;action name="action2" class="com.XXX.Action2" method="methodOfAction2"&gt; &lt;result name="success"&gt;/name.jsp&lt;/result&gt; &lt;/action&gt; </code></pre> <p>Inside the Bean Class(Action)</p> <pre><code>private List&lt;String&gt; lstVariablename; /....Getters and Setters............ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload