You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/01/16 09:38:09 UTC

[GitHub] [servicecomb-java-chassis] whuxiari commented on issue #1522: 接口返回值定义的是ResponseEntity,为什么返回值的Body为空?

whuxiari commented on issue #1522: 接口返回值定义的是ResponseEntity,为什么返回值的Body为空?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1522#issuecomment-575066267
 
 
   通过这样返回,在前端查看Body为空。不是null,是啥都没有。    
   public static ResponseEntity<String> getResponseEntity(XXXXException e) {
           return ResponseEntity.status(HttpStatus.valueOf(e.getCode())).body(e.getMsg());
       }
   
   改成这样抛出异常,前端是可以获取到Body的:
   throw new InvocationException(e.getCode(), e.getMessage(), e.getMsg());

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services