Spring MVC コントローラーから AJAX を使用してすべての顧客のリストを取得しようとしています。コントローラの応答は List を正確に返しています。しかし、AJAX Response から List の要素とそのプロパティを取得する方法がわかりません。コントローラーコードは次のとおりです。
@RequestMapping(value="/ShowAllCustomers", method = RequestMethod.GET)
public @ResponseBody Object AllCustomersList() {
List<Customer> customers= customerService.getAllCustomers();
return customers;
}
クライアント側は次のとおりです。
function AjaxGetCustomers() {
$.ajax({
type : 'GET',
url : 'customers/ShowAllCustomers',//this is url mapping for controller
success : function(response) {
alert(response.get(0).first_name);
//this response is list of object coming from server
},
error : function() {
alert("opps error occured");
}
});
}
しかし、これは機能していません。各 Customer オブジェクトとそのプロパティにアクセスする方法は?
前もって感謝します