Bean Validation handles Java Bean well, but cannot validate basic types, such as the following request for controller, @ Valid will not take effect
@PostMapping("/save")
public Map save(@Email
@Valid
@RequestParam("email")
String email) {
return emailMessage(email);
}
when I was looking up the data, I saw that https://sdqali.in/blog/2015/1.
described the use of @ Validated annotations and the configuration of global exception handlers to solve the problem, but I tried, but without success.
it is impossible to forcibly encapsulate one or two basic type parameters into Java Bean, and what if one more parameter is needed for verification in some places, for example, a request needs to verify email,b request needs to verify email and validcode, so it is unreasonable to forcibly encapsulate Java Bean (email and validcode)
have you encountered it? is there any good solution? Thank you
found here that a user has asked a similar question, but I don"t think the downstairs answer actually solved the problem, so mention it again with a link to his question: https://codeshelper.com/q/10.
.