【问题标题】:Constraints message in validator of play20play20 验证器中的约束消息
【发布时间】:2012-03-22 16:48:23
【问题描述】:

我想为约束验证器提供不同的消息,但我正在徘徊如何做...... 例子

@Constraints.Required
@Constraints.Pattern("\\d{1,6}")
public String thisIsAnInt;

我想要一些东西

@Constraints.Required
    @Constraints.Pattern(message="ThisismyspecificMessage",value=\\d{1,6}")
    public String thisIsAnInt;

用于在表单中使用引导程序正确显示它。

有可能吗? 非常感谢

【问题讨论】:

    标签: playframework-2.0


    【解决方案1】:

    如你所写,你可以使用

    @Constraints.Required(message = "This is field required")
    @Constraints.Pattern(value = "\\d{1,6}", message = "This field must contain from 1 to 6 digits")
    public String thisIsAnInt;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 2016-09-22
      • 1970-01-01
      相关资源
      最近更新 更多