消息(錯誤)顯示
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>
<html:messages id="message" property="activationDate">
<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>
<html:messages id="message" property="activationDate">
<li><bean:write name="message"/></li>
</html:messages>
把Messages換成Errors就是錯誤顯示,為了簡便,經常一個<html:errors/>了事