logic标签的使用规则

项目引入struts后,在WEB-INF中会生成c.tld,struts-html.tld,struts-logic.tld等文件

在jsp中引用相应标签的tld文件。jsp中taglib里的uri和prefix分别对应tld文件中的uri和short-name:

<%@ taglib uri="http://struts.apache.org/tags-logic"  prefix="logic"%>

1.<logic:notEmpty判断bean值是否存在或非空:

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

    <!--高级查询的代码-->

</logic:notEmpty>

2.<logic:equal判断bean是否相等:

<logic:equal    name="fwxx"    property="uid"    value="${sessionScope.user.uid}" ————>通过fwxx对象的uid属性值与value值比较来判断是否相等

    <!--高级查询的代码-->

</logic:equal>

例子:

<c:forEach    items="${list}"    var="fwxx">

    <logic:equal    name="fwxx"    property="uid"    value="${sessionScope.user.uid}"

        <!--高级查询的代码-->

    </logic:equal>

</c:forEach>

3.<logic:iterator显示列表数据:

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

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

</logic:iterator>


超级好用:

演示:

<logic:notEmpty name="leatherRmd">
<logic:iterate id="element" name="leatherRmd" offset="9" length="1">  //offset是从下标第几个元素取,lengthahi取几个数据
<div style="padding: 5px 0px 0px; 124px;"
    class="goodsItem">
    <a href="#" target="_blank">
    <img style="border: currentColor; 64px; height: 64px; margin-right: 8px; float: left;"
            class="goodsimg" border="0" alt="${element.goodsName }"
            src="${ctx}${element.defaultImage}">
    </a>
    <p
        style=" 50px; height: 42px; line-height: 15px; padding-top: 20px;">
        <a title="${element.goodsName }"
            href="#" target="_blank">${element.goodsName }</a>
    </p>
</div>
</logic:iterate>
</logic:notEmpty>

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/shipeng22022/p/4614193.html