J2EE學習筆記(3) Struts Logic Tags

來源:互聯網
上載者:User
Logic Tags
文法應用是 --
<someComparisonTag value="someUserNameValue" cookie="userName"> (cookie specifies the name of the cookie to compare with value)
<someComparisonTag value="en_US" header="Accept-Language"> (header specifies the name of the HTTP header to compare with value)
<someComparisonTag value="someUserNameValue" parameter="username"> (parameter specifies the name of the request parameter to compare with value)
<someComparisonTag name="testBean" property="propNameInTestBean" value="someValue"> (典型)
name指定了bean的名字而property指定了該bean的某個property以便於與value比較, 通常我們還可以加一個scope來限制bean
property is used in conjunction with name to specify a property in the bean specified by name. The property reference can be simple, nested, and/or indexed. For the type of syntax used for property, see the users guide on the Bean Tags.
scope specifies the bean scope which can be page, request, session, application, "any scope" (default)
1) 值比較 Value Comparison: equal, notEqual, greaterEqual, lessEqual, lessThan, greaterThan
比較邏輯是 -- 先試圖convert成long double,並比較; 如果parse失敗就會用String.equalTo()來比較
1) 值比較 Value Comparison: present, notPresent, empty, notEmpty
present看的是某變數/執行個體是否存在於某個限定範圍,empty看的是該執行個體是否為null, "", or collection.isEmpty()==true (only for collection)
2) 子字串匹配 Substring Matching: match, notMatch
match/notMatch 還有一個可選location來指定該substring必須出現在字串開始還是結尾 (location="start/end")
3) Presentation Location: forward, redirect
用法尚不清楚
4) Collection Utilities: iterate (極常用)
<logic:iterate id="searchResultList" name="<%=WebKeys.SEARCH_RESULT_LIST_TWO%>" scope="session">
<bean:write name="searchResultList" property="itemName"/></a>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.