In Spring 3 is it possible to dynamically set the reason of @ResponseStatus?

后端 未结 7 1940
别跟我提以往
别跟我提以往 2021-02-05 02:01

I have a custom exception class annotated to return a given HttpStatus:

@ResponseStatus(value=HttpStatus.BAD_REQUEST, reason=\"Invalid parameter\")
         


        
7条回答
  •  离开以前
    2021-02-05 02:06

    The "reason" is optional, so you can omit that and implements the abstract method public String reason passing the Error. Link: http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/ResponseStatus.html

提交回复
热议问题