1.用ajax传递单个对象参数:
vardata = {};
data['location.site']=$("#site").val();
data['location.room']=$("#room").val();
$.ajax({
type: 'POST',
url:'createLocation',
data:data,
});
注: struts 中的接收参数名必须是location
3.用ajax传递对象数组
$(".class").each(function(i){
var type = $(this).find("[title]").attr("title");
var name = $(this).find("[name]").attr("name");
templates['template['+i+'].name']=name;
templates['template['+i+'].type']=type;
$.ajax({
type: "post",
data:propertyTemplates,
dataType: "json",
url:action,
async:true,
});
注: struts 中的接收参数名必须是templates,且其类型为list而不能说数组,因为struts还不支持数组