1

全部,我想使用@ResponseStatus 向客户端返回一条消息,流程:

@ExceptionHandler(value = { Exception.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "not found mapping please check url")
@ResponseBody
public RestResponse<String> accessDenied() {
    RestResponse<String> restResponse = new RestResponse<String>();
    restResponse.setFailureMessageCn("xxxx");
    restResponse.setFailureMessagePt(messageSource.getMessage(
            "cemetery.operationFailed", null, LocaleUtils.toLocale("pt")));
    restResponse.setSuccess(false);
    restResponse.setBody(null);
    return restResponse;
}

但它不能不工作。提前谢谢!

4

0 回答 0