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);
    }
posted @ 2020-05-01 22:58  CyberPelican  阅读(340)  评论(0编辑  收藏  举报