Learning logic taglib

Source: Internet
Author: User

Nothing to say, all in the code !!

  1. <% @ Page contenttype = "text/html; charset = GBK" %>
  2. <% @ Page import = "Java. util. *" %>
  3. <% @ Taglib uri = "http://struts.apache.org/tags-bean" prefix = "Bean" %>
  4. <% @ Taglib uri = "http://struts.apache.org/tags-html" prefix = "html" %>
  5. <% @ Taglib uri = "http://struts.apache.org/tags-logic" prefix = "logic" %>
  6. <% @ Taglib uri = "http://struts.apache.org/tags-tiles" prefix = "tiles" %>
  7. <! -- Logic: Present Learning -->
  8. <%
  9. Request. setattribute ("uid", "Forrest ");
  10. Session. setattribute ("name", "Forrest he ");
  11. %>
  12. <! -- 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. -->
  13. <Logic: present name = "uid" Scope = "request">
  14. <H2> the specified uid attribute exists and the value is $ {uid} </H2>
  15. </Logic: Present>
  16. <Logic: present name = "name" Scope = "session">
  17. <H2> the specified name attribute exists and the value is $ {name} </H2> <HR>
  18. </Logic: Present>
  19. <! -- Logic: equal learning -->
  20. <! --
  21. <Logic: equal> =
  22. <Logic: notequal>! =
  23. <Logic: greaterthan>
  24. <Logic: greaterequal >>=
  25. <Logic: lessthan> <
  26. <Logic: lessequal> <=
  27. -->
  28. <Logic: equal name = "uid" Scope = "request" value = "Forrest">
  29. <H2> the statement meets the conditions and the content is $ {uid} </H2>
  30. </Logic: equal>
  31. <Logic: notequal name = "uid" Scope = "request" value = "forr">
  32. <H2> the statement does not meet the conditions and the content is not $ {uid} </H2>
  33. </Logic: notequal> <HR>
  34. <! -- Logic: iterator Learning -->
  35. <%
  36. // Collection
  37. // List <string> List = new arraylist <string> ();
  38. Set <string> set = new treeset <string> (); // It can be sorted. arraylist cannot be sorted.
  39. Set. Add ("Forrest ");
  40. Set. Add ("Denny ");
  41. Set. Add ("Miles ");
  42. Set. Add ("Vivian ");
  43. Request. setattribute ("names", set );
  44. // Map
  45. /*
  46. 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.
  47. Output steps: map --> set --> iterator --> map. Entry --> key, Value
  48. Logic: the iterate label converts the map to the map. Entry layer.
  49. */
  50. Map <string, string> map = new treemap <string, string> ();
  51. Map. Put ("1", "one ");
  52. Map. Put ("2", "two ");
  53. Map. Put ("3", "three ");
  54. Pagecontext. setattribute ("num", MAP );
  55. %>
  56. <Logic: iterate id = "col" name = "names" Scope = "request">
  57. <H2 >$ {Col} </H2>
  58. </Logic: iterate>
  59. <Logic: iterate id = "M" name = "num" Scope = "page">
  60. <H2> MAP value: $ {m} --> map key value: $ {M. key} --> the value of map is $ {M. value} </H2>
  61. </Logic: iterate> <HR>
  62. <! -- Iterative logic: iterator Learning -->
  63. <%
  64. List <string> List = NULL;
  65. Map <string, list <string >>_map = new treemap <string, list <string> ();
  66. List = new arraylist <string> ();
  67. List. Add ("1 ");
  68. List. Add ("2 ");
  69. _ Map. Put ("num1", list );
  70. List = new arraylist <string> ();
  71. List. Add ("one ");
  72. List. Add ("II ");
  73. _ Map. Put ("num2", list );
  74. Pagecontext. setattribute ("_ map", _ map );
  75. %>
  76. <Logic: iterate id = "num" name = "_ map" Scope = "page">
  77. <H2> MAP value: $ {num} --> map key value: $ {num. key} --> the value of map is $ {num. value} </H2>
  78. </Logic: iterate>
  79. <Logic: iterate id = "num" name = "_ map" Scope = "page">
  80. <H2> MAP value: $ {num} --> map key value: $ {num. Key} --> </H2>
  81. <Logic: iterate id = "num_value" name = "num" property = "value" Scope = "page">
  82. <H2> MAP value: $ {num_value} </H2>
  83. </Logic: iterate>
  84. </Logic: iterate>

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.