What I'm trying to do is to pass something like this (I'm using the struts2-json plugin)
var object = {param1 : somevalue, param2 : othervalue};
through a $.getJSON()
call. In my Struts2 action I have this two parameters like the following:
public class ActionExample extends ActionSupport {
private Integer param1;
private String param2;
.
.
}
with its respectives setters and getters. This two parameters are for a method in which receives the first param correctly, but the other one always is null and when I sent it from the client side I saw that it has a value. What am I doing wrong?
This is how the call looks like
$.getJSON('ajax/getSomething.action', JSON.stringify(object), function(data){
//response manipulation
.
.
});
Other value for the second parameter should be a string
var object = {param1 : somevalue, param2 : ''+othervalue};
and use
$.getJSON('ajax/getSomething.action', object, function(data){
the parameters would be added by getJSON()
.
Note that your action should be configured properly to handle parameters, i.e. getters/setters, interceptors, etc.