J2EE学习笔记(6) Struts HTML Tags

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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/>了事

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航