這是我的腳本如何從春天控制器列表中的JavaScript
$.ajax({
url: 'request/batch/details',
contentType: 'application/json',
dataType: 'json',
type: 'GET',
success: function (data) {
alert("ok");
},
error: function (jqXHR, textStatus, errorThrown) {
alert("error" + errorThrown);
}
});
,這是我的控制器
@RequestMapping(value = {"/request/batch/details"}, method = RequestMethod.GET, produces = "application/json")
public List<Batch> SentAllBatchs() {
List<Batch> allBatches = service.getAllBatches();
for (Batch allBatche : allBatches) {
System.out.println(allBatche.getBatchName());
}
return allBatches;
}
當我運行這個它拋出一個錯誤
405方法不允許..
我做錯了什麼? 幫我解決這個問題。
此前的問題將錯誤代碼稱爲406,因此,答案是指406錯誤代碼 –