Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I get so parameters in @Controller @RequestMapping method:

@ModelAttribute("myCandidate") @Valid Candidate myCandidate,
BindingResult result

How can I explicit specify validation group for myCandidate ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

The standard java @Valid annotation doesn't support groups. However, Spring now includes an @Validated annotation which does the same job as @Valid, but allows you to specify which groups to use in the validation:

@ModelAttribute("myCandidate") @Validated(UpdateGroup.class) Candidate myCandidate

Note that this annotation is only available in Spring 3.1 and newer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...