springboot2.3.x版本发生异常时,响应的message和exception为空问题

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

原因:因为boot2.3.x版本可能考虑信息安全问题,把以下两个值默认为

server:
error:
include-message: never
include-exception: false

发生异常是返回

{
"timestamp": 1632713940269,
"status": 500,
"error": "Internal Server Error",
"message": "",
"path": "/xxxx"
}

 

修改后

server:
error:
include-message: always
include-exception: true

发生异常是返回

{
"timestamp": 1632713940269,
"status": 500,
"error": "Internal Server Error",
"exception": "com.xxxx.xxxxException",
"message": "非法访问",
"path": "/xxxxx"
}

原因:更改默认错误页面的内容默认情况下,错误消息和任何绑定错误都不再包含在默认错误页中。这降低了向客户泄露信息的风险。服务器。Error, include-message和server.error。Include-binding-errors可用于分别控制消息和绑定错误的包含。支持的值为always、on-param和neyen w。

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: Spring