Validation체크
오류는 아닌데 내가 원하는 형태가 아니면 메세지로 체크한다.
https://github.com/Moonseonhyeon/SpringBoot-validate/commit/9696ee3aadfbf20d3a985c4849abdbb7bbbf7158
validation · Moonseonhyeon/SpringBoot-validate@9696ee3
github.com

자바 버전 8로! 아니면 배포할 때? 문제?


더보기
server:
  port: 8080
  servlet:
    context-path:  /
    encoding:
      charset:  UTF-8
      enabled: true
      force: true
      
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/security?serverTimezone=Asia/Seoul
    username: cos
    password: cos1234
      
  jpa:
    hibernate:
      ddl-auto: create #update create update non
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl #파스칼 표기법으로설정
    show-sql: true #sql문 보기
    
여기 까지 해놓고 서버 실행시켜서 콘솔창 보면 실행이 잘 된다.
서버끄고
모델 ProjectTask
컨트롤러
repository 만들기


ProjectTaskRepository 생성


Valid는 오류는 아닌데 잘못된것을 잡아내려고 사용
Summary cannot be blank를 따내서 사용할 예정

오류가 나면 BindingResult가 모두 낚아챈다.
@Valid 붙여두면 BindingResult에 오류들을 다 등록을 해주는데 위와 같이 DI만 하면 된다.

작성
이 Dto는 공공데이터 했을때 받은 값들을 보면 이해가 쉬움

작성

사용자에게 보여줄 메세지

그리고 테스트!

컨트롤러마다 바인딩에러
스프링컨테이너 (IOC)에 bindingResult
aop
함수 들어가지 직전! 직후! 데이터도 받아서 처리 할 수 있다.
응답전에만
'Spring Boot' 카테고리의 다른 글
| 스프링에서 구글 FCM push 메세지 구현 (0) | 2020.08.13 | 
|---|---|
| AOP (0) | 2020.08.11 | 
| form form 태그 delete, put요청 (0) | 2020.08.11 | 
| cors정책 (0) | 2020.08.11 | 
| JSP에서 (0) | 2020.08.11 |