第六次学习:
1.逻辑判断标签:
2.逻辑判断标签(数值):
2.逻辑判断是否为空:
1.逻辑判断标签:
java代码: |
1 2 定义一些变量 3 <jsp:useBean id="bean" scope="page" class="org. apache. struts. webapp. exercise. TestBean" /><% 4 String bool1 = " true"; 5 String bool2 = " false"; 6 String str1 = "This is a string"; 7 String str2 = "Less than"; 8 String str3 = "XYZ greater than"; 9 %> 10 相等 11 <logic:equal name="bean" property="booleanProperty" value="<%= bool1 %>">equal</logic:equal> 12 不等 13 <logic:notEqual name="bean" property="booleanProperty" value="<%= bool1 %>">notEqual</logic:notEqual> 14 15 大于等于 16 <logic:greaterEqual name="bean" property="stringProperty" value="<%= str1 %>">greaterEqual</logic:greaterEqual> 17 大于 18 <logic:greaterThan name="bean" property="stringProperty" value="<%= str1 %>">greaterThan</logic:greaterThan> 19 小于等于 20 <logic:lessEqual name="bean" property="stringProperty" value="<%= str1 %>">lessEqual</logic:lessEqual> 21 小于 22 <logic:lessThan name="bean" property="stringProperty" value="<%= str1 %>">lessThan</logic:lessThan> 23 不等 24 <logic:notEqual name="bean" property="stringProperty" value="<%= str1 %>">notEqual</logic:notEqual> 25 26 |
2.逻辑判断标签(数值):
java代码: |
1 2 定义变量 3 <jsp:useBean id="bean" scope="page" class="org. apache. struts. webapp. exercise. TestBean" /><% 4 String doub1 = " 321. 0"; 5 String doub2 = " 111. 0"; 6 String doub3 = " 333. 0"; 7 String long1 = " 321"; 8 String long2 = " 111"; 9 String long3 = " 333"; 10 String short1 = " 987"; 11 String short2 = " 654"; 12 String short3 = " 999"; 13 %> 14 等于 15 <logic:equal name="bean" property="doubleProperty" value="<%= doub2 %>">equal</logic:equal> 16 大于等于 17 <logic:greaterEqual name="bean" property="doubleProperty" value="<%= doub2 %>">greaterEqual</logic:greaterEqual> 18 大于 19 <logic:greaterThan name="bean" property="doubleProperty" value="<%= doub2 %>">greaterThan</logic:greaterThan> 20 小于等于 21 <logic:lessEqual name="bean" property="doubleProperty" value="<%= doub2 %>">lessEqual</logic:lessEqual> 22 小于 23 <logic:lessThan name="bean" property="doubleProperty" value="<%= doub2 %>">lessThan</logic:lessThan> 24 不等于 25 <logic:notEqual name="bean" property="doubleProperty" value="<%= doub2 %>">notEqual</logic:notEqual> 26 27 |
2.逻辑判断是否为空:
java代码: |
1 2 <jsp:useBean id="bean" scope="page" class="org. apache. struts. webapp. exercise. TestBean" /> 3 <table border=" 1"> 4 <tr> 5 <th>Test Type</th> 6 <th>Correct Value</th> 7 <th>Test Result</th> 8 </tr> 9 <tr> 10 <td>missing bean, no property attribute</td> 11 <td>empty</td> 12 <td> 13 <logic:empty name="missingBean">empty</logic:empty> 14 <logic:notEmpty name="missingBean">notEmpty</logic:notEmpty> 15 </td> 16 </tr> 17 <tr> 18 <td>not-missing bean, no property attribute</td> 19 <td>notEmpty</td> 20 <td> 21 <logic:empty name="bean">empty</logic:empty> 22 <logic:notEmpty name="bean">notEmpty</logic:notEmpty> 23 </td> 24 </tr> 25 <tr> 26 <td> null</td> 27 <td>empty</td> 28 <td> 29 <logic:empty name="bean" property="nullProperty">empty</logic:empty> 30 <logic:notEmpty name="bean" property="nullProperty">notEmpty</logic:notEmpty> 31 </td> 32 </tr> 33 <tr> 34 <td>empty string</td> 35 <td>empty</td> 36 <td> 37 <logic:empty name="bean" property="emptyStringProperty">empty</logic:empty> 38 <logic:notEmpty name="bean" property="emptyStringProperty">notEmpty</logic:notEmpty> 39 </td> 40 </tr> 41 <tr> 42 <td>non-empty string</td> 43 <td>notEmpty</td> 44 <td> 45 <logic:empty name="bean" property="stringProperty">empty</logic:empty> 46 <logic:notEmpty name="bean" property="stringProperty">notEmpty</logic:notEmpty> 47 </td> 48 </tr> 49 <tr> 50 <td>empty collection</td> 51 <td>empty</td> 52 <td> 53 <logic:empty name="bean" property="emptyListProperty">empty</logic:empty> 54 <logic:notEmpty name="bean" property="emptyListProperty">notEmpty</logic:notEmpty> 55 </td> 56 </tr> 57 <tr> 58 <td>non-empty collection</td> 59 <td>notEmpty</td> 60 <td> 61 <logic:empty name="bean" property="listProperty">empty</logic:empty> 62 <logic:notEmpty name="bean" property="listProperty">notEmpty</logic:notEmpty> 63 </td> 64 </tr> 65 <tr> 66 <td>empty map</td> 67 <td>empty</td> 68 <td> 69 <logic:empty name="bean" property="emptyMapProperty">empty</logic:empty> 70 <logic:notEmpty name="bean" property="emptyMapProperty">notEmpty</logic:notEmpty> 71 </td> 72 </tr> 73 <tr> 74 <td>non-empty map</td> 75 <td>notEmpty</td> 76 <td> 77 <logic:empty name="bean" property="mapProperty">empty</logic:empty> 78 <logic:notEmpty name="bean" property="mapProperty">notEmpty</logic:notEmpty> 79 </td> 80 </tr> 81 <tr> 82 <td>unsupported object</td> 83 <td>notEmpty</td> 84 <td> 85 <logic:empty name="bean" property="intProperty">empty</logic:empty> 86 <logic:notEmpty name="bean" property="intProperty">notEmpty</logic:notEmpty> 87 </td> 88 </tr> 89 </table> 90 |