I am trying to convert List of objects into json with the help of jackson-mapper-asl
libraries, but in response i got http 406
error. jackson-mapper-asl
libraries are on my class path. Following is my Spring MVC controller code:
@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;
}
My Ajax request code:
$.ajax({
url: url+"/"+parentId,
type: 'GET',
success: function(result) {
var arr = $.parseJSON(result);
-----------------------
With spring 4
, we need to use following dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
</dependency>
The jackson-mapper-asl
is used with spring 3.x
. Thanks to @Master Slave for valid comment. Click here for more information: Spring 4 RestController JSON: characteristics not acceptable according to the request "accept" headers