大家好我是新来的Spring MVC,所以我对这个框架没有什么想法。我想要做的就是在我的视图中刷新一个div,并使用通过hibernate查询进行过滤的项目,该项目可以正确打印到标准输出。Spring MVC中ajax GET请求的内部服务器错误
由于某种原因,我不知道我得到一个500;内部服务器错误,当我尝试通过ajax获取请求。 我改变了控制器的返回类型,我最初的想法是使用带有可选参数的默认索引控制器。
查看:
Nothing found
JS文件
function filterItems(value) {
$("#itemListContainer").empty();
$.ajax({
method: "GET",
//dataType: "json",
url: "filterItems.htm",
data: {
type: value
},
success: function (data) {
if (data) {
$("#itemListContainer").html(data);
} else {
console.log(xhr.responseText);
alert("failure");
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
}
控制器:
@RequestMapping(value = "/filterItems", method = RequestMethod.GET)
public @ResponseBody List filterItems(@RequestParam(value = "type", required = false) String type) {
List items = new ArrayList();
try {
items = itemDao.getItems(type);
} catch (Exception e) {
e.printStackTrace();
}
return items;
}
任何帮助将不胜感激。提前致谢!!
2016-11-15
Juan M
+0
请包括相关的堆栈跟踪。 –
+0
“服务器遇到内部错误,导致无法完成此请求”。没有例外,我可以从eclipse控制台看到。我很乐意粘贴catalina.out日志条目,但我不知道在Mac OSX中找到那些内容 –