본문 바로가기
반응형

BindingResult2

[Error] An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments 아래와 같은 에러를 만났다.An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments 원인은 Valid 를 사용할 경우 Error 나 BindingResult 를 잡을수가 있는데,Valid 바로 다음에 Errors 나 BindingResult 가 나와야한다.Valid 관련해서는 아래 참고 포스팅 참고 바란다. 두 코드를 보면 올바른 코드와 잘못된 코드를 확인 가능하다.(스택오버플로우 사이트 참고)올바른 코드@RequestMapping(value = "/catowners", method = RequestMe.. 2024. 8. 17.
@Valid annotation (BindingResult, Error)(유효성 검사) 지난번에 다뤘던 포스팅 중에서 not null관련 포스팅도 존재하고, jackson 관련 포스팅도 존재한다. 둘의 공통점은 dto 등에서 변수에 설정을 걸어주는것이다. 하지만 이 둘 말고도 또다른 annotation이 존재하는데 그것들에 대해서 잠깐 소개 하고 valid annotation으로 한번에 유효성 검증을 하는 법에 대해서 소개해보려고 포스팅을 작성한다. 위에 두가지 경우에 대해서는 아래 참고 포스팅을 참고해보길 바란다. 오늘 사용할 annotation 관련은 import javax.validation.constraints.*; 임포트를 따른다. Anotation 제약조건 @Size(min=,max=) 문자열, 배열등의 크기가 만족하는가? @Pattern(regex=) 정규식을 만족하는가? @M.. 2022. 8. 22.
반응형