我有一个JSP页面,我在其中显示客户名称,我需要能够在点击客户名称时显示任何客户的完整数据,所以我做了一个小的Ajax调用来从DB渲染客户对象所以我可以在我的JSP页面中显示它。但我总是得到错误代码500(内部服务器错误),所以有人可以告诉我: 我究竟在这做错了什么?以及如何解决它? 2.有没有比我尝试更好的方法?
由于
function loadSingleCustomerdata(customerid){
var customerData="?customerID="+customerid;
alert(customerData);
$.ajax({
url: "LoadSingleCustomerData"+customerData,
success: function(customerDataRec){
alert(customerDataRec.firstName);
},
error: function (request, status, error) {
alert(request.responseText);
}
});
}
控制器方法:
@RequestMapping(value = "admin/customers/LoadSingleCustomerData")
public @ResponseBody
Customer getSingleCustomerData(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long id= Long.parseLong(request.getParameter("customerID"));
Customer customer=icustomerservice.getCustomerByPK(id);
return customer;
}