Tôi đã cố gắng áp dụng nhiều chú thích @Pattern đến một lĩnh vực duy nhất:Nhiều mẫu của Regex @ cho 1 trường?
@Pattern(regexp = "(?=.*[0-9])", message = "Password must contain one digit.")
@Pattern(regexp = "(?=.*[a-z])", message = "Password must contain one lowercase letter.")
@Pattern(regexp = "(?=.*[A-Z])", message = "Password must contain one uppercase letter.")
@Pattern(regexp = "(?=\S+$)", message = "Password must contain no whitespace.")
private String password;
Tuy nhiên, tôi không thể làm điều này. Tôi muốn các thông báo riêng lẻ mỗi vi phạm ràng buộc regex trên trường mật khẩu. Điều này có thể không?
Cách thay thế của tôi là sử dụng thẻ JSF 2.0 f: validatorRegex.
Bạn có thể tạo xác nhận của bạn chú thích riêng –