如何在春天休息时使用@ResponseStatus

时间:2013-03-31 09:19:46

标签: spring rest response

全部 我想使用@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;
}

但它无法正常工作。 谢谢!

0 个答案:

没有答案