Zam*_*boo 18 java spring resttemplate
我不熟悉Spring RestTemplate.
但对于这个项目,我必须使用Spring RestTemplate发送POST调用以使用rest api.
我正在使用此代码:
String restCall = restTemplate.postForObject(url+restParm, null, String.class);
Run Code Online (Sandbox Code Playgroud)
这工作正常.
我想要恢复HTTP状态代码(例如:200 OK.).我怎么能这样做?谢谢.
hyn*_*ess 43
您使用postForEntity方法如下...
ResponseEntity<String> response = restTemplate.postForEntity(url+restParm, null, String.class);
HttpStatus status = response.getStatusCode();
String restCall = response.getBody();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
52641 次 |
| 最近记录: |