可以从属性文件读取模式正则表达式吗? [英] Is possible to read the pattern regex from property file?

查看:100
本文介绍了可以从属性文件读取模式正则表达式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从属性文件中读取正则表达式?

Is possible to read the regexp from property file?

@Pattern(regexp = "{A-Za-z0-9}*")

private String name;

推荐答案

如果您正在使用Bean验证参考实现Hibernate Validator,则可以使用

If you're using the Bean Validation reference implementation Hibernate Validator, you could declare the constraint programmatically using the API for constraint declaration. You'd have to read the regular expression from the property file yourself and then pass it when configuring the constraint via the API.

这篇关于可以从属性文件读取模式正则表达式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆