springboot项目,请求可以进入controller,但返回结果报404

来源:互联网 发布:淘宝推广首选晨昊网络 编辑:程序博客网 时间:2024/06/11 10:25

请求地址:
http://localhost:8080/asset-mqtt/mqtt/publish/hellomqtt11

返回值:

{    "timestamp": 1507703410086,    "status": 404,    "error": "Not Found",    "message": "Not Found",    "path": "/asset-mqtt/mqtt/publish/mqtt/publish/hellomqtt11"}

可以发现请求地址是/asset-mqtt/mqtt/publish/hellomqtt11,但返回值报的错误path是:/asset-mqtt/mqtt/publish/mqtt/publish/hellomqtt11

经查询,错误原因是在方法上没有加@ResponseBody,由于我是Springboot项目,所以,不在方法上加@ResponseBody,而是把@Controller改为@RestController(@RestController包含了@ResponseBody)
问题解决。

阅读全文
0 0
原创粉丝点击