I am using AJAX to fetch a list of Company objects from database. I have added @ResponseBody to my controller method. And jackson-mapper-asl dependency. Below is AJAX call:
$.ajax({
type : 'GET',
url : $("#contextpath").val() + '/getCompanyList',
success : function(response) {
alert(response);
}
});
Controller method:
@RequestMapping(value="/getCompanyList", method=RequestMethod.GET)
public @ResponseBody List<Company> getCompanyList() {
logger.debug("reached controller getCompanyList");
return companyServices.getCompanyList();
}
But I am getting error
No converter found for return value of type: class java.util.ArrayList
Secondly, Is there a way to return list of Java objects to AJAX without converting it to JSON ?