Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling

Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling

今天在调试代码的时候,遇到了这个异常,但是是debug级别的,刚开始没有留意,但是因为返回值一直跟我想要的不一样,

所以也是在网上找了好多资料,

但是跟我想要的结果还是偏差太大了,自己经过慢慢的调试,也是发现了错误的所在.

{
    "timestamp": "2019-08-16 00:21:50",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/industry//user/addHeaded"
}

调试之前遇到这样的错误,但是调试成功以后,就一切才正常.

{
    "data": null,
    "code": 200,
    "msg": "请求成功",
    "timestamp": "2019-08-16 00:24:26",
    "ok": true
}

都是因为一个注解的原因@ResposeBody,没有让返回值以流的形式返回去,所以才会出现上面的异常

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11361391.html