gpt4 book ai didi

playframework-2.0 - play20 验证器中的约束消息

转载 作者:行者123 更新时间:2023-12-03 23:40:50 25 4
gpt4 key购买 nike

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

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

我想要一些东西
@Constraints.Required
@Constraints.Pattern(message="ThisismyspecificMessage",value=\\d{1,6}")
public String thisIsAnInt;

用于在表单中使用 bootstrap 正确显示它。

有可能的?
多谢

最佳答案

正如你所写,你可以使用

@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;

关于playframework-2.0 - play20 验证器中的约束消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9826817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com