Struts Tab--logic Summary

Source: Internet
Author: User

1. Logic:empty
The label is used to determine if it is empty. If empty, the content embedded in the tag body is processed. This label is used for the following situations:

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>
The sentence is equivalent to:
if (Userlist.isempty ()) {
...
}
2. Logic:notempty
The label is applied exactly as opposed to the Logic:empty label, slightly.
3. logic:equal
The label is equal to the comparer.
Eg1. Compares whether the user's state attribute is 1, and if 1, the output is "enabled";
<logic:equal name= "User" property= "state" value= "1" >
Enable
</logic:equal>
EG2. If the value in the above example is obtained dynamically, for example through the bean:write output, because struts does not support tag nesting, the El can be used to solve the problem.
<logic:equal name= "charge" property= "num" value= "${business.num}" >
......
</logic:equal>
4. Logic:notequal
The label is the opposite of logic:equal, using a similar method, slightly.
5. Logic:forward
This tab is used to implement page guidance and to find the global forward of the configuration file.
eg. <logic:forward name= "index"/>
6. Logic:greaterequal
is greater than or equal to the comparison character.
eg. When a student's result is greater than or equal to 90 o'clock, the output is "excellent":
<logic:greaterequal name= "student" property= "score" value= ">"
Excellent
</logic:greaterEqual>
7. Logic:greaterthan
This is greater than the comparator, using the same method as logic:greaterequal, slightly;
8. Logic:lessequal
This is less than or equal to the comparator, using the same method as logic:greaterequal, slightly;
9. Logic:lessthan
This is less than the comparison, using the same method as logic:greaterequal, slightly;
Ten. Logic:match
This label compares objects for equality;
Eg1. Check that the Name property within the request scope contains the "Amigo" string:
<logic:match name= "name" scope= "Request" value= "Amigo" >
There is a "amigo" string in the <bean:write name= "name"/>.
</logic:match>
EG2. Check that the Name property within the request scope has "Amigo" as the starting string:
<logic:match name= "name" scope= "Request" value= "Amigo" location= "Start" >
<bean:write name= "name"/> with "Amigo" as the starting string.
</logic:match>
Eg3.
<logic:match header= "user-agent" value= "Windows" >
You are running the Windows system
</logic:match>
Logic:notmatch.

This label is used to compare objects differently, in contrast to the logic:match meaning, using a method similar to, slightly.
Logic:messagepresent.
The label is used to determine whether the Actionmessages/actionerrors object exists;
eg. If there is an error message, Output it all:
<logic:messagepresent property= "Error" >
<bean:write name= "ErrMsg"/>
</logic:messagepresent >
Logic:messagesnotpresent.
This label is used to determine if the Actionmessages/actionerrors object does not exist and is used in a similar way to logic:messagepresent, slightly
Logic:present.
This label is used to determine if the request object passed parameters exist.
Eg1. When the user object and its name attribute are present in the request, the corresponding string is output:
<logic:present name= "user" property= "name" >
Both the user object and the Name property of the object exist
</logic:present>
EG2. If there is a javabean named "user", output the corresponding string:
<logic:present name= "User" >
There is a javabean named "User".
</logic:present>
Eg3.
<logic:present header= "User-agent" >
We got a user-agent header.
</logic:present>
Logic:notpresent.
This tag is used to determine if the Request object pass parameter does not exist, the meaning is opposite to the logic:present, the use method is similar, slightly.
Logic:redirect.
This tab is used to implement page steering and can pass parameters.
Eg1. <logic:redirect href= "http://www.chinaitlab.com"/>

Logic:iterator.
Used to display a list of collection values (list, Arraylist,hashmap, and so on).
Eg1. Output the user name in the user list (userllist) individually:
<logic:iterate id= "user" name= "userlist" >
<bean:write name= "user" property= "name"/><br>
</logic:iterate>
EG2. Output the names of two users starting with 1 from the list of users
<logic:iterate id= "user" name= "userlist" indexid= "index" offset= "1" length= "2" >
<bean:write name= "index"/>.<bean:write name= "user" property= "name"/><br>
</logic:iterate>
Eg3. Nested examples of Logic:iterator tags
<logic:iterate id= "user" indexid= "index" name= "UserList" >
<bean:write name= "index"/&GT;. <bean:write name= "user" property= "name"/><br>
<logic:iterate id= "Address" name= "user" property= "AddressList" length= "3" offset= "1" >
<bean:write name= "Address"/><br>
</logic:iterate>
</logic:iterate>

Struts Tab--logic Summary

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.