//不使用@valid进行校验
Set<ConstraintViolation<CommonValidator>> validates = validator.validateValue(CommonValidator.class, "name", null);
for (ConstraintViolation<CommonValidator> validate : validates) {
ConstraintViolationImpl validate2= (ConstraintViolationImpl)validate;
Annotation annotation = validate2.getConstraintDescriptor().getAnnotation();
Class<? extends Annotation> aClass = annotation.annotationType();
String messageTemplate = validate2.getConstraintDescriptor().getMessageTemplate();
System.out.println(validate.getMessage());
if (aClass.equals(NotEmpty.class)){
System.out.println("messageTemplate:"+messageTemplate);
throw new RuntimeException("not empty异常了");
}
}
System.out.println("成功");

最新文章

  1. Java基础知识系列——目录操作
  2. iOS Block 内存管理的探讨
  3. 在Eclipse中手动安装pydev插件,eclipse开发python环境配置
  4. PHP中float变量转换为int时,结果有误的问题!
  5. MyBatis知多少(20)MyBatis读取操作
  6. 中间件、MetaQ入门学习
  7. ftime() 系统时间
  8. 【BZOJ】【1324】王者之剑
  9. SVN服务器使用(二)
  10. android学习—— LayoutInflater的使用
  11. Arrays和Collections 对于sort的不同实现原理
  12. SQL Server中的变更捕获技术--简单部署
  13. A customized combobox with JQuery
  14. struts2 在 Action 或 Interceptor 中获取 web.xml 中配置的 &lt;context-param&gt; 参数 (这是我的第一篇博文,哈哈。)
  15. jQuery 练习:tab 切换
  16. mysql:general_log 日志、数据库线程查询、数据库慢查询
  17. js 自定义类Android吐司提示框
  18. .NET Core微服务之路:利用DotNetty实现一个简单的通信过程
  19. video自动禁止全屏
  20. Binomial Coefficient(二项式系数)

热门文章

  1. pycharm取消代码长度的竖线
  2. ImGui引入深度测试的方法
  3. 负载均衡做集群时关于的session不均衡的解决方案
  4. Git Please commit your changes or stash them before you merge.
  5. QP之QEP事件分配流程分析
  6. springboot AOP配置
  7. Homebrew macOS飞速安装教程
  8. css - content-visibility
  9. svn 中的trunk,tags,branches分别是什么意思?
  10. 推荐2个可用于毕设的微信小程序