在Controller中,为了给客户端直接返回json数据,使用了JSONObject,想直接返回Json格式
1 |
|
经过测试,发现Postman测试数据是可以写入数据库的,但是Postman返回却不是result,而是
1 | { |
最后发现原因是:pring boot uses jackson as default serializer and you're trying to return JSONObject itself. Jackson does not know how to serialize it.If you want to return dynamic json you can use Map
具体戳这里。
改为:
1 |
|
再次测试,成功。

注:转载文章请注明出处,谢谢~