我想知道如何将参数从JSP传递给控制器。 我试图通过ajax调用发送,但它将进入错误函数
HTML:
<input type="submit" name="syncSubmit" value="synchronize" id="submitSync" >
JSP:
$("#submitSync").click(function() {
var campaignId = [];
var accountSe_Id = $ {
accountSe_Id
};
var accountId = $ {
accountId
};
$("#selectedCampaigns option").each(function() {
campaignId.push({
"campaignId": $(this).val()
});
});
$.ajax({
type: "POST",
url: "/partial-synch.json",
processData: true,
data: {
campaignId: JSON.stringify(campaignId),
accountSe_Id: accountSe_Id,
accountId: accountId
},
dataType: "json",
success: function(data) {
},
error: function(data) {
alert("fail");
}
});
return false;
});
控制器:
@RequestMapping(value = "/partial-synch.json", method = RequestMethod.POST)
@ResponseBody
public Object[] partialSync(
@RequestParam("campaignId") String campaignId,
@RequestParam("accountSe_Id") long accountSe_Id,
@RequestParam("accountId") long accountId) {
Object[] resposneBody = new Object[1];
}