Ich arbeite an einem Frühlingsprojekt.Wie kann ich eine Kopfzeile mit ungültiger Antwort senden?
Ich mache das gerade.
public ResponseEntity<?> create(@RequestBody final Some entity) {
// persist the entity here
final URI location = uriComponentsBuilder.path("{id}").buildAndExpand(entity.getId()).toUri();
return ResponseEntity.created(location).build();
}
Und ich fand die @ResponseStatus
.
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody @NotNull final BaseType entity) {
// persist the entity here
// Location header to where?
}
Gibt es eine Möglichkeit Location
Header mit dieser Art und Weise zu schicken?
https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-ann-return-types –
@JBNizet Wird 'ResponseEntity >' sowieso arbeiten? –
Warum testeest du es nicht selbst? –