我试图通过jackson-mapper-asl
库的帮助将对象列表转换为json,但作为响应,我得到http 406
错误。 jackson-mapper-asl
库位于我的课程路径中。以下是我的Spring MVC控制器代码:Spring MVC:jackson-mapper-asl不适用于Spring 4
@RequestMapping(value="/find-sub-categories/{parentId}", method=RequestMethod.GET)
@ResponseBody public List<ProductCategory> findSubCategories(@PathVariable(value="parentId") ProductCategory productCategory) {
logger.info("In ADMIN findSubCategories Contoller AJAX GET");
List<ProductCategory> categories = productCategoryService.findAllChildProductCategoriesByParent(productCategory);
return categories;
}
我的Ajax请求代码:
$.ajax({
url: url+"/"+parentId,
type: 'GET',
success: function(result) {
var arr = $.parseJSON(result);
-----------------------
你使用错误的杰克逊依赖关系检查这里http://stackoverflow.com/questions/26825276/spring-4-restcontroller-json-characteristics-not-acceptable-according-to-the-re – 2015-02-23 14:42:40
你加入?contentType:“应用程序/ json; charset = utf-8“,dataType:”json“,也是ver杰克逊的使用?对Jackson的支持一直专注于2.0以上的春季4 – 2015-02-23 16:24:24