-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostXXX.java
More file actions
61 lines (47 loc) · 2.14 KB
/
postXXX.java
File metadata and controls
61 lines (47 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//<start id="postForLocation"/>
URI postForLocation(String url, Object request, Object... uriVariables)
throws RestClientException;
URI postForLocation(
String url, Object request, Map<String, ?> uriVariables)
throws RestClientException;
URI postForLocation(URI url, Object request) throws RestClientException;
//<end id="postForLocation" />
//<start id="postForObject"/>
<T> T postForObject(URI url, Object request, Class<T> responseType)
throws RestClientException;
<T> T postForObject(String url, Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException;
<T> T postForObject(String url, Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
//<end id="postForObject"/>
//<start id="postForEntity"/>
<T> ResponseEntity<T> postForEntity(URI url, Object request,
Class<T> responseType) throws RestClientException;
<T> ResponseEntity<T> postForEntity(String url, Object request,
Class<T> responseType, Object... uriVariables)
throws RestClientException;
<T> ResponseEntity<T> postForEntity(String url, Object request,
Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException;
//<end id="postForEntity"/>
//<start id="postForObject_object"/>
public Spitter postSpitterForObject(Spitter spitter) {
RestTemplate rest = new RestTemplate();
return rest.postForObject("http://localhost:8080/Spitter/spitters",
spitter, Spitter.class);
}
//<end id="postForObject_object"/>
//<start id="postForEntity_object"/>
RestTemplate rest = new RestTemplate();
ResponseEntity<Spitter> response = rest.postForEntity(
"http://localhost:8080/Spitter/spitters", spitter, Spitter.class);
Spitter spitter = response.getBody();
URI url = response.getHeaders().getLocation();
//<end id="postForEntity_object"/>
//<start id="postForLocation_object"/>
public String postSpitter(Spitter spitter) {
RestTemplate rest = new RestTemplate();
return rest.postForLocation("http://localhost:8080/Spitter/spitters",
spitter).toString();
}
//<end id="postForLocation_object"/>