Spring version 4.2.0, Hibernate 4.1.4
Here is my Controller function:
@RequestMapping(value = "/mobile/getcomp", method = RequestMethod.GET)
@ResponseBody
public List listforCompanies() {
List listOfCompanies= new ArrayList();
listOfCompanies = companyManager.getAllCompanies();
return listOfCompanies;
}
Jackson JSON mapper dependency in Pom.xml:
org.codehaus.jackson
jackson-mapper-asl
${jackson.version}
Getting the list in my ArrayList, but when returning the following error is shown:
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [/IrApp] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList] with root cause
java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList
at org.springframework.util.Assert.isTrue(Assert.java:68)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:124)
Link to the example I'm following.
解决方案
Add the below dependency to your pom.xml:
com.fasterxml.jackson.core
jackson-databind
2.5.0