当前位置:编程学习 > JSP >>

J2EE学习笔记(6) Struts HTML Tags

HTML Tags
一些公用的tag attributes在HTMLTagLib里的含义前后一致,它们是
name: ActionForm bean的实例名,如果name不存在,<html:form>所关联的formBean会生效。
property: property既决定了生成的html的fieldname,也决定了该field的值 via formBean.getThisProperty
value: value决定了生成html的field的value,注意它不是bean的propertyName
<html:html>和普通<html>不同的是,1)自动加上hidden token 2)自动加上context_root
剩下的以后慢慢加。。。
消息(错误)显示
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/>了事

补充:Jsp教程,J2EE/EJB/服务器 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,