添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version: 2.3.x

i build a spring boot project, i need to response error message in a RESTful API, so i do that:

-pom-

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
</parent>
 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
  </dependencies>

-Java Code-

  @RequestMapping(value = "/bad-token", method = RequestMethod.GET)
    public void bad(HttpServletResponse response) throws IOException {
        response.sendError(401, "this is bad token");
        return;

and i find the ‘message’ in the api result info is blank,like that

-2.3.0-

"timestamp": "2020-11-05T09:44:45.497+0000", "status": 401, "error": "Unauthorized", "message": "", "path": "/bad"

this problem has not occurred in previous versions , i switched to 2.2.10.RELEASE and i got the 'message'

-2.2.10-

"timestamp": "2020-11-05T09:44:45.497+0000", "status": 401, "error": "Unauthorized", "message": "this is bad token", "path": "/bad"

I tested and found this problem in any version greater than 2.3.0.RELEASE.
I'm not sure it is a bug

This is the expected default behaviour in Spring Boot 2.3. Please see the relevant section of the release notes for details.

Originally posted by @wilkinsona in #22049 (comment)