如何在Struts2中的特定<div>元素中显示验证消息

tus*_*sar 6 struts2

我是Struts 2的新手,在保持页面布局方面遇到了这个问题:

<s:form action="abc.action"><br>
    <s:textfield key="name" label="Name" /><%--here I need to display errormessage for `name`--%>
    <br>
    <s:textfield key="email" label="Email" /><%--here I need to display errormessage for `email`--%>
    <br>
    <s:submit>
</s:form>
Run Code Online (Sandbox Code Playgroud)

我正在为我的动作类使用xml-validator,这很好用.但验证错误消息显示在fieldname和text-box上.但我希望它后来各自的文本框(在另一个html容器内).好心提醒.

Qua*_*ion 11

如果您习惯于编写HTML,请切换到简单主题.

在struts.xml中可能是最好的地方:

<struts>
  <constant name="struts.ui.theme" value="simple" />
</struts>
Run Code Online (Sandbox Code Playgroud)

然后只需使用fielderror标记将错误放在您想要的字段中.

熟悉Struts2标签是一件好事:http://struts.apache.org/release/2.3.x/docs/tag-reference.html