Domanda

I follow the example listed here when I load the page or press any button on the grid the method execute is called twice. I want to call it just once. What can I do?

È stato utile?

Soluzione

Rename (or remove, since in the example is not used) the getJSON method.

public String getJSON()
{
   return execute();
}

JSON plugin may be calling all your methods that start with "get" in an attempt to serialize them for output.

See: Struts2 Action being called twice if result type is json

Edit:

You can also use the includeProperties or excludeProperties params to avoid the default behavior of call all the methods that start with "get", see: Problem with Json plugin in Struts 2

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top