【发布时间】:2018-01-04 20:25:07
【问题描述】:
我有一个 'startDate 和 'endDate' 的列表,它通过 $http Post 请求传递给控制器,但它抛出了主题中提到的错误。我的代码如下
$scope.saveUpdateAnualAudit=function(auditPlanLst)
{
$scope.auditCycleLst = [];
$scope.auditCycleLst = JSON.stringify(auditPlanLst);
//auditPlanLst is a list of startDate and endDate captured from the view
console.log("$scope.auditCycleLst "+$scope.auditCycleLst);
$http({
method: 'POST',
url: "PlanAuditController/saveUpdateAnualAudit/"+$scope.auditCycleLst,
}).success(function(data, status) {
})
.error(function(data, status) {
$scope.errorMsg= "<strong>Error!</strong> Failed to retrieve AuditPlan of .";
$scope.showErrorAlert = true;
$scope.showSuccessAlert = false;
});
}
}]);
控制器代码如下
@RequestMapping(value = "/saveUpdateAnualAudit/{auditCycleLst}", method = RequestMethod.POST)
public String saveUpdateAnualAudit(@RequestBody List<AuditCycleJsonVo> auditCycleLst) {
try {
System.out.println("Saved to db");
}catch(Exception e){
e.printStackTrace();
}
return "planAudits";
}
AuditCycleJsonVo 类如下
public class AuditCycleJsonVo {
private String startDate;
private String endDate;
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
}
我无法通过它抛出的错误找到它出错的地方,它没有到达控制器。
【问题讨论】: