Reputation: 171
These are the String-type parameters I want to send.
I have to send two parameters to DB and use them to query data, and get the data back as JSON array type.
I also got jackson-databind library in my project.
var startDate = picker.startDate.format('YY-MM-DD');
var endDate = picker.endDate.format('YY-MM-DD');
var dates = { "startDate": startDate, "endDate": endDate };
This is the Ajax code
$.ajax({
url: "selectCouponByTerm",
type : "POST",
data : dates,
contentType : "application/json; charset=utf-8",
success : function(data){
dataTable.attr('data', JSON.stringify(data)).trigger("create");
console.log(data);
},
error : function(e){
console.log(e.status);
}
})
Then in the controller,
@PostMapping("/selectCouponByTerm")
@ResponseBody
public List<Coupon> selectCouponByTerm(@RequestBody String startDate,
@RequestBody String endDate) {
return "adminService.selectCouponByTerm(startDate, endDate)";
}
it gives me Type mismatch: cannot convert from String to List<Coupon>
error.
Upvotes: 0
Views: 35