Page reload prevention in Struts 2

I am currently working on a small web application, and this is the first time I use Struts2. This is what I am trying to achieve.

The Struts2 JSP page in the form post invokes the struts action. Once this action completes this task, I need to return to the calling JSP without reloading any page (avoid postback). how can i achieve. Can someone please help me ?.

+4
source share
2 answers

It's called AJAX (don't joke).

In Struts2, you can use the Struts2-jQuery Plugin to achieve this quite easily.

+5
source

As AndreaLigios said, you can achieve this using the struts-j request plugin.

  • Create a remote page to display the result.
  • Using <sj:sbmit targets="[div_id]" /> on the main page to submit the form
  • Add a div to the home page to display the deleted page. <div id="[div_id]" />

  • In your struts.xml, just return the deleted page as a result of your action.

+2
source

All Articles