2013-05-20 51 views

回答

0

不,您不能從限制驗證程序中訪問驗證元素的名稱。雖然(通過getPropertyPath()),但是由於違反了結果而暴露出來。

0

在Hibernate實現,你可以使用反射ConstraintValidatorContext.basePath.currentLeafNode.name

0

您可以通過以下EXP

((ConstraintValidatorContextImpl) context).getConstraintViolationCreationContexts().get(0).getPath() 
訪問路徑它