Thursday, 26 September 2013

Struts 2 action called up twice.

Problem :

If you are using JSON plugin with struts2 then you might end up with this problem. your action get called up twice even when you have define it only once and you are firing ajax only at once.


Solution:

This is happening because JSON plugin is calling all your methods that start with "get" in an attempt to serialize them for output.Try to rename the method name other then "getxxxxx()".



method name start with getXX:
public String getName() {
    return "Rakesh";
}

method name changed to fetchXX:

public String fetchName() {
   return "Rakesh";
}

Hopefully this will work.

No comments:

Post a Comment

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...