Search code examples
jquerystrutsstruts2-jqueryjqgridstruts2-json-plugin

I'm using the Struts2-jQuery grid plugin and the action is called twice


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?


Solution

  • 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