您可以
ExceptionHandler为
MessagingException和设置
HTTPStatus,以指示响应有错误(egz。
BAD_REQUEST)
@ExceptionHandler(MessagingException.class)@ResponseStatus(HTTPStatus.BAD_REQUEST)@ResponseBodypublic ErrorView handleMessagingException(MessagingException ex) { // do something with exception and return view}在AngularJS中,您可以像这样从资源服务中捕获它:
MessagingService.get({idCommande: 1}, function (data) {// this is success}, function (reason) {// this is failure, you can check if this is a BAD_REQUEST and parse response from exception handler};使用时几乎相同
$http。



