消息(错误)显示
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("userForm.insert", info.getUserName());
messages.add("activationDate", new ActionMessage("userForm.active", info.getDateLength());
如下可以显示所有消息,并用<li>将它们放入一个list,再加上可定制的header/footer
<html:messages id="message" header="errors.header" footer="errors.footer">
<li><bean:write name="message"/></li>
</html:messages>
如下可以指定只显示某种message
<html:messages id="message" property="<%= org.apache.struts.action.ActionMessages.GLOBAL_MESSAGE %>">
<li><bean:write name="message"/></li>
</html:messages>
把Messages换成Errors就是错误显示,为了简便,经常一个<html:errors/>了事
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("userForm.insert", info.getUserName());
messages.add("activationDate", new ActionMessage("userForm.active", info.getDateLength());
如下可以显示所有消息,并用<li>将它们放入一个list,再加上可定制的header/footer
<html:messages id="message" header="errors.header" footer="errors.footer">
<li><bean:write name="message"/></li>
</html:messages>
如下可以指定只显示某种message
<html:messages id="message" property="<%= org.apache.struts.action.ActionMessages.GLOBAL_MESSAGE %>">
<li><bean:write name="message"/></li>
</html:messages>
把Messages换成Errors就是错误显示,为了简便,经常一个<html:errors/>了事
博客介绍了消息(错误)显示的代码实现。通过创建ActionMessages对象添加消息,利用<html:messages>标签显示所有消息或指定消息,还可定制header/footer。将Messages换成Errors可用于错误显示,也常用<html:errors/>简化操作。
2361

被折叠的 条评论
为什么被折叠?



