2013-05-20 47 views

回答

0

不,您不能从限制验证程序中访问验证元素的名称。虽然(通过getPropertyPath()),但是由于违反了结果而暴露出来。

0

在Hibernate实现,你可以使用反射ConstraintValidatorContext.basePath.currentLeafNode.name

0

您可以通过以下EXP

((ConstraintValidatorContextImpl) context).getConstraintViolationCreationContexts().get(0).getPath() 
访问路径它