Spring MVC:jackson-mapper-asl不适用于Spring 4

Har*_*ara 2 spring json spring-mvc http-status-code-406

我试图在jackson-mapper-asl库的帮助下将对象列表转换为json ,但作为响应我得到了http 406错误.jackson-mapper-asl图书馆在我的班级路径上.以下是我的Spring MVC控制器代码:

@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;
}
Run Code Online (Sandbox Code Playgroud)

我的Ajax请求代码:

$.ajax({
            url: url+"/"+parentId,
            type: 'GET',
            success: function(result) {
                var arr = $.parseJSON(result);
----------------------- 
Run Code Online (Sandbox Code Playgroud)

Har*_*ara 12

有了spring 4,我们需要使用以下依赖:

<dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-databind</artifactId>
 <version>2.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

jackson-mapper-asl被使用spring 3.x.感谢@Master Slave的有效评论.单击此处获取更多信息: Spring 4 RestController JSON:根据请求"accept"标头不可接受的特性