您的位置:首页 > 编程语言 > Java开发

struts中常用的标签

2009-10-05 11:16 204 查看
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

==============================================================

<html:errors/>显示错误信息

==============================================================

<p2><a href="#" onclick="history.back()">返回上一页</a></p2>

======================================================

<logic:present name="all" scope="request">

<logic:iterate id="item" name ="all" scope="request">

${item.itemname}<br>

<logic:iterate id="subitem" name="item" property="subitems">

|-${subitem.subname}<br>

</logic:iterate>

</logic:iterate>

</logic:present >

=============================================================

使用bean:size 得到集合数据记录数

<bean:size id = "count" name ="list" />

共找到${count}条记录

=============================================================

bean:define标签的使用

<bean:define id = "dataList" type="java.util.List" name="list" scope="request" />

共找到<%=dataList.size()%>条记录

=============================================================

使用bean:write格式化输出 代替DecimalFormat和DataFormat

<logic : iterate id="fwxx" name="list">

<bean:write name="fwxx" property="#,###"/>元

<bean:write name="fwxx" property="yyyy"年MM月dd日/>

</logic>

====================================================

记住下面这种连接的写法技巧,说不准以后能用的到:

<logic : iterate id ="fwxx" name="list">

<a href='detail.do?fwid=${fwxx.fwid}'>${fwxx.title}</a>

</logic:iterate>

=========================================================

<logic:notEmpty name="user" scope="session">

.......

</logic:notEmpty>

======================

<html:select property="condition.qxid" style="width:80px">

<html:optionsCollection name="qxList" label="px" value="qxid"/>

</html:select>

上述代码中集合的每个元素都是QX实体对象,qx和qid都是QX实体对象的属性名,如果有{1,海淀区}的对象,将输出到客户端得html代码为

“<option value="1">海淀区</option>”;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: