spring controller里面返回JSONObject与返回String的不同

原理待分析

有个应用问题,当返回的对象有空属性时,即consumerCar里面有的字段没有用set填充,JSONObject会报500错误,不会打印日志,也不会报异常,应该是spring内部问题

JsonUtil.getOkJsonResult(consumerCar)

改成返回String就可以了

JsonUtil.getOkJsonResult(consumerCar).toString()
原文地址:https://www.cnblogs.com/govoid/p/5413799.html