org.apache.bval.cdi.BValExtension
@Path("/example")
public class ExampleResource {
@POST
public Response createExample(@Valid Example example) {
// do something
}
}
@Path("/example")
public class ExampleResource {
@Inject
private Validator validator;
@POST
public Response createExample(Example example) {
Set> violations = validator.validate(example);
if (!violations.isEmpty()) {
throw new ConstraintViolationException(violations);
}
// do something
}
}
上一篇:ApacheTomcat中存在哪些安全限制绕过漏洞?如何修复这些漏洞?
下一篇:ApacheTomEEWebprofile8-无法从Johnzon更改JSonRest提供程序到Jackson。