springmvc返回json数据

来源:互联网 发布:ipowerl魔术软件 编辑:程序博客网 时间:2024/06/05 21:52

环境:springmvc4.2.6 idea maven
问题:HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class com.util.BaseResponse

这里写图片描述

解决方案:

这里写图片描述

解决思路:
以前一直以为@ResponseBody会自动将返回值转换为对象,结果测试以后发现并不是这样的,还需要上面说的包,一下是我的测试
这里写图片描述

同样,返回字符串,ModelAndView一样可用。

原创粉丝点击