Category Archives: STruts2

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.

79 total views, 1 views today

IE 8 issue :Downloading pop up comes out when firing ajax for uploading file


Downloading pop up comes out when firing ajax for uploading file
This pop up comes out because ajax call after success need a response type in IE-8. So we can set the response by any of these way.

If you are using Struts2 you can simply set the content type in the parameter.

Struts.Xml:

<result name="success" type="json">
<param name="contentType">text/html</param>
</result>


you can achive this using java you just need to set the result response in the JSON
return Json(result, "text/html");

77 total views, 1 views today