Mixed Use of struts2 labels and jstl labels

Source: Internet
Author: User

 

1. I used jstl labels all the time, and later I started to use some struts2 labels. After all, some struts2 labels are more convenient to use.

The struts2 label and jstl label are often used in projects, such as custom tags or cyclic tags.

1. Use struts2 in jstl

<C: forEach var = "ee" items = "$ {requestScope. serviceList}">

Jstl: <c: out value = "$ {ee. id}"> </c: out>

El: $ {ee. id}

Struts2: <s: property value = "Ettr. ee. id"/>

</C: forEach>

 

When you use the struts2 label to retrieve the variables of the jstl label, you can set the scope from the scope

If not, use Ettr to set the value.

2. Get the value from the jstl tag

<C: set var = "ctime" value = "$ {el. createtime}" scope = "request"/>

<C: set var = "ctime2" value = "$ {el. createtime}"/>

<S: property value = "# request. ctime"/>

<S: property value = "Ettr. ctime2"/>

 

3. Use jstl in the struts2 label

<S: iterator value = "# request. serviceList" id = "bs">

Struts2: <s: property value = "# bs. keyid"/>

El: $ {bs. keyid}

Jstl: <c: out value = "$ {bs. keyid}"> </c: out>

</S: iterator>

 

4. values from the struts2 tag

<! -- Number type -->

<S: set name = "pp" value = "11"> </s: set>

Struts2: <s: property value = "# pp"/>

El: $ {pp}

Jstl: <c: out value = "$ {pp}"> </c: out>

<! -- String type -->

<S: set name = "pp2" value = "'abc'" scope = "request"> </s: set>

Struts2: <s: property value = "# request. pp2"/>

El: $ {pp2}

Jstl: <c: out value = "$ {pp2}"> </c: out>

 

Author: pcenshao

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.