I have been dealing with this kind of situations here and there. In my Struts 2 application, I'm using an AJAX call to send a String array to an Action class. What I'm trying to do is something like this: page_1.jsp
-> Action A
-> Action B
-> Action C
. However, what is actually happening is page_1.jsp
-> Action A
-> Action B
-> Action C
-> Action C
, i.e. the last Action class is being called twice.
page_1.jsp:
<button class="ink-button double-vertical-space all-25 dynamicButton"
id="finish" disabled> Finish </button>
[...]
$('#finish').click(function(event)
{
var fids = $('input:checkbox').filter(':checked').map(function ()
{
return this.id;
}).get();
$.ajax
({
method: "POST",
url: "A.action",
data: { fids : fids },
traditional: true,
success:
function()
{
// I know that the problem is here.
// Currently I have it like this, so it's understandable
// why action C is getting called 2 times,
// I just don't know how to fix it.
window.location = "C.action";
}
});
});
struts.xml:
<action name="A" class="action.A" method="execute">
<result name="success" type="redirectAction"> B </result>
</action>
<action name="B" class="action.B" method="execute">
<result name="success" type="redirectAction"> C </result>
</action>
<action name="C" class="action.C" method="execute">
<result name="success"> /page_2.jsp </result>
</action>