【问题标题】:Play Framework custom validation errors with multiple String parameters带有多个字符串参数的 Play Framework 自定义验证错误
【发布时间】:2012-03-19 18:01:10
【问题描述】:

我正在尝试在 Play! 中使用多个参数设置自定义验证错误,但我的验证参数似乎未正确呈现。

我已经定义在messages:

validation.customerror=This is first param "%s", and this is the second "%s"

在我执行的代码中:

validation.addError("","validation.customerror", "FIRST", "SECOND");

我得到:

This is first param "", and this is the second "FIRST"

而不是

This is first param "FIRST", and this is the second "SECOND"

想法?

【问题讨论】:

    标签: java validation playframework messages


    【解决方案1】:

    使用如下索引号定义您的验证消息:

    validation.customerror=This is first param "%1$s", and this is the second "%2$s"
    

    查看Play Framework documentation 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-29
      • 2015-03-17
      • 1970-01-01
      • 2013-01-28
      • 1970-01-01
      • 1970-01-01
      • 2014-04-24
      • 1970-01-01
      相关资源
      最近更新 更多