如何实现struts2中的{0}字段验证消息
struts2中如何实现参数化消息。 在actioname-validation.xml中我有
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="common.required">
<argo key="common.family" />
</message>
</field-validator>
</field>
资源文件,
common.required = {0} is required.
common.family = Family
我尝试过类似的东西。如何实现这一目标?
How to achieve parameterized message in struts2.
in actioname-validation.xml i have
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="common.required">
<argo key="common.family" />
</message>
</field-validator>
</field>
resource file i have,
common.required = {0} is required.
common.family = Family
some thing like this i tried. how to achive this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇文章解释了如何做你想做的事。其要点是您定义验证规则如下:
然后在您的 .properties 文件中,您将具有以下内容:
This article explains how to do what you want. The gist of it is that you'd define your validation rule as follows:
And then in your .properties file, you'd have the following:
它给了我我所期望的
应用程序资源,
It gives me, what i expected
Application Resources,
也可以通过如下方式解决
It might be also resolved as follows