Nothing to say, all in the code !!
- <% @ Page contenttype = "text/html; charset = GBK" %>
- <% @ Page import = "Java. util. *" %>
- <% @ Taglib uri = "http://struts.apache.org/tags-bean" prefix = "Bean" %>
- <% @ Taglib uri = "http://struts.apache.org/tags-html" prefix = "html" %>
- <% @ Taglib uri = "http://struts.apache.org/tags-logic" prefix = "logic" %>
- <% @ Taglib uri = "http://struts.apache.org/tags-tiles" prefix = "tiles" %>
- <! -- Logic: Present Learning -->
- <%
- Request. setattribute ("uid", "Forrest ");
- Session. setattribute ("name", "Forrest he ");
- %>
- <! -- If scope is not specified, search for the four attribute ranges in sequence. As long as present or notpresent is found, the statement in the corresponding tag is executed. -->
- <Logic: present name = "uid" Scope = "request">
- <H2> the specified uid attribute exists and the value is $ {uid} </H2>
- </Logic: Present>
- <Logic: present name = "name" Scope = "session">
- <H2> the specified name attribute exists and the value is $ {name} </H2> <HR>
- </Logic: Present>
- <! -- Logic: equal learning -->
- <! --
- <Logic: equal> =
- <Logic: notequal>! =
- <Logic: greaterthan>
- <Logic: greaterequal >>=
- <Logic: lessthan> <
- <Logic: lessequal> <=
- -->
- <Logic: equal name = "uid" Scope = "request" value = "Forrest">
- <H2> the statement meets the conditions and the content is $ {uid} </H2>
- </Logic: equal>
- <Logic: notequal name = "uid" Scope = "request" value = "forr">
- <H2> the statement does not meet the conditions and the content is not $ {uid} </H2>
- </Logic: notequal> <HR>
- <! -- Logic: iterator Learning -->
- <%
- // Collection
- // List <string> List = new arraylist <string> ();
- Set <string> set = new treeset <string> (); // It can be sorted. arraylist cannot be sorted.
- Set. Add ("Forrest ");
- Set. Add ("Denny ");
- Set. Add ("Miles ");
- Set. Add ("Vivian ");
- Request. setattribute ("names", set );
- // Map
- /*
- The map set needs to be output through iterative tags. The map set itself does not directly support iterative output. For output, map must be converted to iterator.
- Output steps: map --> set --> iterator --> map. Entry --> key, Value
- Logic: the iterate label converts the map to the map. Entry layer.
- */
- Map <string, string> map = new treemap <string, string> ();
- Map. Put ("1", "one ");
- Map. Put ("2", "two ");
- Map. Put ("3", "three ");
- Pagecontext. setattribute ("num", MAP );
- %>
- <Logic: iterate id = "col" name = "names" Scope = "request">
- <H2 >$ {Col} </H2>
- </Logic: iterate>
- <Logic: iterate id = "M" name = "num" Scope = "page">
- <H2> MAP value: $ {m} --> map key value: $ {M. key} --> the value of map is $ {M. value} </H2>
- </Logic: iterate> <HR>
- <! -- Iterative logic: iterator Learning -->
- <%
- List <string> List = NULL;
- Map <string, list <string >>_map = new treemap <string, list <string> ();
- List = new arraylist <string> ();
- List. Add ("1 ");
- List. Add ("2 ");
- _ Map. Put ("num1", list );
- List = new arraylist <string> ();
- List. Add ("one ");
- List. Add ("II ");
- _ Map. Put ("num2", list );
- Pagecontext. setattribute ("_ map", _ map );
- %>
- <Logic: iterate id = "num" name = "_ map" Scope = "page">
- <H2> MAP value: $ {num} --> map key value: $ {num. key} --> the value of map is $ {num. value} </H2>
- </Logic: iterate>
- <Logic: iterate id = "num" name = "_ map" Scope = "page">
- <H2> MAP value: $ {num} --> map key value: $ {num. Key} --> </H2>
- <Logic: iterate id = "num_value" name = "num" property = "value" Scope = "page">
- <H2> MAP value: $ {num_value} </H2>
- </Logic: iterate>
- </Logic: iterate>