这是我的剧本
$.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方法不允许..
我做错了什么吗? 帮我解决这个问题。
答案 0 :(得分:0)
如果在pom.xml
中缺少,请添加以下mvn工件<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1.1</version>
</dependency>
并检查你是否有
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
答案 1 :(得分:0)
安德特在您的请求中添加前导斜杠;)