我正在编写一个Spring Boot应用程序。我的控制器有2个自定义请求标头。我执行了几次测试,只是发现标题不存在时我的应用程序返回了“ 404”。
但是我期望这会导致'400'错误?
有人能详细说明为什么会这样吗?我应该如何正确处理呢?正如告诉服务的使用者,标头丢失了吗?
@RestController("fundsConfirmationController")
@RequestMapping(
value="/accounts/{accountId}/funds-confirmations",
headers = {"X-CAF-MSGID", "X-AccessToken"}
)
public class FundsConfirmationController implements FundsConfirmationControllerI{
private FundsConfirmationServiceI fundsConfirmationService;
@Autowired
public FundsConfirmationController(FundsConfirmationServiceI fundsConfirmationService){
this.fundsConfirmationService = fundsConfirmationService;
}
@GetMapping(
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
public ResponseEntity<?> fundsConfirmation(@RequestHeader(value="X-CAF-MSGID") String messageId,
@RequestHeader(value="X-AccessToken") String accessToken,
FundsConfirmationRequest requestParams) { ... }