ResponseEntity

Posted kikochz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ResponseEntity相关的知识,希望对你有一定的参考价值。

    @RequestMapping("/test1")
    public ResponseEntity<?> testControllerAdvice(String id) {
        if (StringUtils.isEmpty(id)) {
            throw new UserNotExistException(id);
        }
        //能设置返回的状态码,和请求头 可以拆解为@ResponseBody和@ResponseStatus
        return new ResponseEntity<String>("正常", HttpStatus.BAD_REQUEST);
    }

以上是关于ResponseEntity的主要内容,如果未能解决你的问题,请参考以下文章