javascript
@responseBody java_java-如何使用@ResponseBody从Spring Controller返回JSON数据
春季版本4.2.0,休眠4.1.4這是我的ArrayList函數(shù):
@RequestMapping(value = "/mobile/getcomp", method = RequestMethod.GET)
@ResponseBody
public List listforCompanies() {
List listOfCompanies= new ArrayList();
listOfCompanies = companyManager.getAllCompanies();
return listOfCompanies;
}
ArrayList中的Jackson映射器依賴關(guān)系:
org.codehaus.jackson
jackson-mapper-asl
${jackson.version}
在我的ArrayList中獲取列表,但返回時顯示以下錯誤:
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)
鏈接到我正在關(guān)注的示例。
總結(jié)
以上是生活随笔為你收集整理的@responseBody java_java-如何使用@ResponseBody从Spring Controller返回JSON数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 调试 gdb_android
- 下一篇: php url %,php常用的url处