Struts1.2.4 learning experience! (7)

xiaoxiao2021-03-06  56

Seventh study: 1. iteration display content

Java code:

1

2

3 <% @ Taglib URI = "/ Tags / Struts-Bean" prefix = "bean"%>

4 <% @ Taglib Uri = "/ Tags / Struts-Logic" prefix = "logic"%>

5

6

7 Test Struts-Logic Iterate Tags </ Title></p> <p>8 </ hEAD></p> <p>9 <body bgcolor = "white"></p> <p>10 Define LIST variables</p> <p>11%</p> <p>12</p> <p>{</p> <p>...}</p> <p>13 Java.</p> <p>Util.</p> <p>ArrayList List =</p> <p>New java.</p> <p>Util.</p> <p>ArrayList</p> <p>(</p> <p>);</p> <p>14 List.</p> <p>Add</p> <p>("First"</p> <p>);</p> <p>15 List.</p> <p>Add</p> <p>("SECOND"</p> <p>);</p> <p>16 List.</p> <p>Add</p> <p>("Third"</p> <p>);</p> <p>17 List.</p> <p>Add</p> <p>("Fourth"</p> <p>);</p> <p>18 List.</p> <p>Add</p> <p>("Fiffh"</p> <p>);</p> <p>19</p> <p>20 pagecontext.</p> <p>SetaTribute</p> <p>("List", List, GeContext.</p> <p>Page_scope</p> <p>);</p> <p>21 definition array</p> <p>twenty two</p> <p>Int IntaRray</p> <p>[</p> <p>] =</p> <p>New</p> <p>int</p> <p>[</p> <p>]</p> <p>twenty three</p> <p>{</p> <p>0,</p> <p>10,</p> <p>20,</p> <p>30,</p> <p>40</p> <p>}</p> <p>24 pagecontext.</p> <p>SetaTribute</p> <p>("INTARRAY", INTARRAY, PageContext.</p> <p>Page_scope</p> <p>);</p> <p>25</p> <p>}</p> <p>26%></p> <p>27 <div align = "center"></p> <p>28 <H1> Test Struts-Logic Iterate Tag </ h1></p> <p>29 </ div></p> <p>30 instantiate bean</p> <p>31 <jsp: usebean id = "bean" scope = "page"</p> <p>Class = "ORG.</p> <p>Apache.</p> <p>Struts.</p> <p>WebApp.</p> <p>EXERCISE.</p> <p>TestBean "/></p> <p>32 <JSP: Usebean ID = "List" scope = "Page"</p> <p>Class = "Java.</p> <p>Util.</p> <p>ArrayList "/></p> <p>33 <h3> test</p> <p>1 - Iterate Display String array</p> <p>[</p> <p>0 ..</p> <p>4</p> <p>] </ h3></p> <p>34 <ol></p> <p>35 <logic: iped = "element" name = "bean" property = "stringArray" indexid = "index"></p> <p>36 <li></p> <p>37 <em></p> <p>38 <bean: Write name = "element" /></p> <p>39 </ em></p> <p>[</p> <p>40 <bean: Write name = "index" /></p> <p>] </ li></p> <p>41 </ logic: Iterate></p> <p>42 </ ol></p> <p>43 <h3> test</p> <p>2 - Iterate display array</p> <p>[</p> <p>0 ..</p> <p>2</p> <p>] </ h3></p> <p>44 <ol></p> <p>45 <logic: iped = "element" name = "bean" proty = "stringArray" indexid = "index" length = "</p> <p>3 "></p> <p>46 <li></p> <p>47 <em></p> <p>48 <bean: Write name = "element" /></p> <p>49 </ em></p> <p>[</p> <p>50 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>51 </ logic: Iterate></p> <p>52 </ ol></p> <p>53 <h3> test</p> <p>3 - Iterate display array</p> <p>[</p> <p>3 ..</p> <p>4</p> <p>] </ h3></p> <p>54 <ol></p> <p>55 <logic: Iterate ID = "Element" name = "bean" proty = "stringArray" indexid = "index" offset = "</p> <p>3 "></p> <p>56 <li></p> <p>57 <em></p> <p>58 <bean: Write Name = "Element" /></p> <p>59 </ em></p> <p>[</p> <p>60 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>61 </ logic: Iterate></p> <p>62 </ ol></p> <p>63 <h3> test</p> <p>4 - Iterate display array</p> <p>[</p> <p>1..</p> <p>3</p> <p>] </ h3></p> <p>64 <ol></p> <p>65 <logic: iped = "element" name = "bean" proty = "StringArray" indexid = "index" offset = "</p> <p>1 "Length ="</p> <p>3 "></p> <p>66 <li></p> <p>67 <em></p> <p>68 <bean: Write Name = "Element" /></p> <p>69 </ em></p> <p>[</p> <p>70 <bean: Write Name = "index" />] </ li></p> <p>71 </ logic: Iterate></p> <p>72 </ ol></p> <p>73 <h3> test</p> <p>5 - Iterate display</p> <p>List </ h3></p> <p>74 <ol></p> <p>75 <logic: iped = "item" name = "list" indexid = "index"></p> <p>76 <li></p> <p>77 <em></p> <p>78 <bean: Write Name = "item" /></p> <p>79 </ em></p> <p>[</p> <p>80 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>81 </ logic: Iterate></p> <p>82 </ ol></p> <p>83 <h3> test</p> <p>6 - Iterate display</p> <p>List</p> <p>[</p> <p>0 ..</p> <p>2</p> <p>] </ h3></p> <p>84 <ol></p> <p>85 <logic: Iterate ID = "Item" Name = "List" indexid = "index" offset = "</p> <p>0 "Length ="</p> <p>3 "></p> <p>86 <li></p> <p>87 <em></p> <p>88 <bean: Write name = "item" /></p> <p>89 </ em></p> <p>[</p> <p>90 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>91 </ logic: Iterate></p> <p>92 </ ol></p> <p>93 <h3> test</p> <p>7 - Iterate display</p> <p>List</p> <p>[</p> <p>2..</p> <p>4</p> <p>] </ h3></p> <p>94 <ol></p> <p>95 <logic: Iterate ID = "Item" Name = "List" indexid = "index" offset = "</p> <p>2 "Length ="</p> <p>3 "></p> <p>96 <li></p> <p>97 <em></p> <p>98 <bean: Write name = "item" /></p> <p>99 </ em></p> <p>[</p> <p>100 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>101 </ logic: Itereate></p> <p>102 </ ol></p> <p>103 <H3> Test</p> <p>8 - Iterage over an</p> <p>Int arch </ h3></p> <p>104 <ol></p> <p>105 <logic: Iterate ID = "item" name = "INTARRAY" indexid = "index"> 106 <li></p> <p>107 <em></p> <p>108 <bean: Write Name = "item" /></p> <p>109 </ em></p> <p>[</p> <p>110 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>111 </ logic: Iterate></p> <p>112 </ ol></p> <p>113 <H3> Test</p> <p>9 - Iterage over an</p> <p>Int Array</p> <p>[</p> <p>0 ..</p> <p>2</p> <p>] </ h3></p> <p>114 <ol></p> <p>115 <logic: iped = "item" name = "INTARRAY" indexid = "index" length = "</p> <p>3 "></p> <p>116 <li></p> <p>117 <em></p> <p>118 <bean: Write Name = "item" /></p> <p>119 </ em></p> <p>[</p> <p>120 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>121 </ logic: Iterate></p> <p>122 </ ol></p> <p>123 <H3> Test</p> <p>10 - Iterage over an</p> <p>Int Array</p> <p>[</p> <p>2..</p> <p>4</p> <p>] </ h3></p> <p>124 <ol></p> <p>125 <logic: Iterate ID = "Item" name = "INTARRAY" indexid = "index" offset = "</p> <p>2 "Length ="</p> <p>3 "></p> <p>126 <li></p> <p>127 <em></p> <p>128 <bean: Write Name = "item" /></p> <p>129 </ em></p> <p>[</p> <p>130 <bean: Write Name = "index" /></p> <p>] </ li></p> <p>131 </ logic: Iterate></p> <p>132 </ ol></p> <p>133 </ body></p> <p>134 </ html></p> <p>135</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-113257.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="113257" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.040</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'zVtbhlwqbvMr0PEyuHQvvi4mXrJRIGqmVte7Ewyca4VNtdYTRVFuItKbkF8pCMmxDetCtORJNQbZiJKU4mDDdQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>