私はSpringプロジェクトに取り組んでいます。無効な応答でヘッダーを送信するにはどうすればよいですか?
私は現在これをやっています。
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();
}
そして私は@ResponseStatus
を見つけました。
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody @NotNull final BaseType entity) {
// persist the entity here
// Location header to where?
}
このようにしてLocation
ヘッダーを送信する方法はありますか?
https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-ann-return-types –
@JBNizetは 'ResponseEntity >'とにかく動作しますか? –
あなたは自分でそれをテストしてみませんか? –