Struts tag example-Logic

Source: Internet
Author: User

Address: http://www.bianceng.cn/Programming/Java/201103/25125.htm

 

1. Logic: empty

This label is used to determine whether it is null. If it is null, the content embedded in the label body will be processed. This label is used in the following scenarios:

1) when the Java object is null;

2) When the string object is;

3) When isempty () in the Java. util. Collection object returns true;

4) When isempty () in the Java. util. map object returns true.

Eg.
<Logic: Empty name = "userlist">
...
</Logic: Empty>
This sentence is equivalent:
If (userlist. isempty ()){
...
}

2. Logic: notempty

The application of this tag is exactly the opposite of the logic: Empty tag.

3. Logic: equal

The label is equal to the comparison operator.

Eg1. compare whether the user's status attribute is 1. If it is 1, the output is "enabled ";

<Logic: equal name = "user" property = "state" value = "1">

Enable

</Logic: equal>

Eg2. if the value in the previous example is dynamically obtained, for example, the bean: Write output is required. Because struts does not support label nesting, El can be used to solve this problem.

<Logic: equal name = "charge" property = "num" value = "$ {business. Num}">

......

</Logic: equal>

4. Logic: notequal

This label indicates the opposite of logic: equal. It is used in a similar way, slightly.

5. Logic: Forward

This label is used to implement page orientation and find the global forward of the configuration file.

Eg. <logic: Forward name = "Index"/>

6. Logic: greaterequal

Is a comparison character greater than or equal.

Eg. When a student's score is greater than or equal to 90, the output is "excellent ":

<Logic: greaterequal name = "student" property = "score" value = "90">
Excellent
</Logic: greaterequal>

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.