首页 > spring 4 纯javaconfig配置的项目:注解@Pattern 里面的regexp如何引入properties的值 ?

spring 4 纯javaconfig配置的项目:注解@Pattern 里面的regexp如何引入properties的值 ?

我使用的是spring 4 javaconfig配置没有任何的xml。
下面的代码:

@PropertySource(value = "classpath:valid.properties")
public class Role implements Serializable {

    @Id
    private String id;
    /**
     * 角色名称
     */
    @Pattern(regexp = "^[a-zA-Z0-9_]{6,32}$")
    private String name;

我在这个通过 @PropertySource 引入了properties文件
虽然可以通过@Value 来获取到properties的值 , 但是 regexp无论如何都无法写入properties的值编译都不能通过,到底该如何写 ?

类似下面的写法都不对 :

@Pattern(regexp = @Value("${name}"))
@Pattern(regexp = "${name}")

但是@pattern还有一个属性 message 就可以这样写 : message = "${name}"

regexp 该如何获取到properties的值 ?


我帮你问问朋友
http://www.yl1001.com/group_article/7001468401005683.htm?classic_id=7681468830725785#comment_7681468830725785
朋友说不太明白使用Pattern注解是想实现什么功能。可以在这个帖子下交流一下

【热门文章】
【热门文章】