3. BookMarket/src/main/Java 폴더에 com.springmvc.validator 패키지를 생성합니다. 이 패키지에 BookId 클래스를 생성하고 다음 내용을 작성합니다.

    코드13-8 BookId.java

    package com.springmvc.validator;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    import java.lang.annotation.Retention;
    import javax.validation.Constraint;

     

    @Constraint(validatedBy=BookIdValidator.class)
    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface BookId {

        String message() default "";
        Class<?>[] groups() default {};
        Class<?>[] payload() default {};
    }
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.