J2EE學習筆記(6) Struts HTML Tags

來源:互聯網
上載者:User
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/>了事

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.