JSTL标签

  1. <%@pagelanguage="java"contentType="text/html;charset=GB18030"
  2. pageEncoding="GB18030"%>
  3. <%@taglibprefix="c"uri="http://java.sun.com/jsp/jstl/core"%>
  4. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <metahttp-equiv="Content-Type"content="text/html;charset=GB18030">
  8. <title>测试jstl核心库</title>
  9. </head>
  10. <body>
  11. <h1>测试jstl核心库</h1>
  12. <hr>
  13. <li>测试c:out</li><br>
  14. hello(default):<c:outvalue="${hello}"/><br>
  15. hello(el表达式):${hello}<br>
  16. hello(default="123"):<c:outvalue="${abc}"default="123"/><br>
  17. hello(default="123"):<c:outvalue="${abc}">123</c:out><br>
  18. bj(defalut):<c:outvalue="${bj}"/><br>
  19. bj(escapeXml="true"):<c:outvalue="${bj}"escapeXml="true"/><br>
  20. bj(escapeXml="false"):<c:outvalue="${bj}"escapeXml="false"/><br>
  21. bj(el表达式):${bj}<br>
  22. <p>
  23. <li>测试c:set和c:remove</li><br>
  24. <c:setvalue="123"var="temp"/>
  25. temp:${temp}<br>
  26. <c:removevar="temp"/>
  27. temp:${temp}<br>
  28. <p>
  29. <li>测试条件控制标签c:if</li><br>
  30. <c:iftest="${v1ltv2}"var="v">
  31. v1小于v2<br>v=${v}<br>
  32. </c:if>
  33. <c:iftest="${emptyv3}">
  34. v3为空<br>
  35. </c:if>
  36. <c:iftest="${emptyv4}">
  37. v4为空<br>
  38. </c:if>
  39. <p>
  40. <li>测试条件控制标签c:choose,c:when,c:otherwise</li><br>
  41. <c:choose>
  42. <c:whentest="${v1ltv2}">
  43. v1小于v2<br>
  44. </c:when>
  45. <c:otherwise>
  46. v1大于v2<br>
  47. </c:otherwise>
  48. </c:choose>
  49. <c:choose>
  50. <c:whentest="${emptyv4}">
  51. v4为空<br>
  52. </c:when>
  53. <c:otherwise>
  54. v4不为空<br>
  55. </c:otherwise>
  56. </c:choose>
  57. <p>
  58. <li>测试循环控制标签c:forEach</li><br>
  59. <tableborder="1">
  60. <tr>
  61. <td>姓名</td>
  62. <td>年龄</td>
  63. <td>所属组</td>
  64. </tr>
  65. <c:choose>
  66. <c:whentest="${emptyuserlist}">
  67. <tr>
  68. <tdcolspan="3">没有符合条件的数据!</td>
  69. </tr>
  70. </c:when>
  71. <c:otherwise>
  72. <c:forEachitems="${userlist}"var="u">
  73. <tr>
  74. <td>${u.username}</td>
  75. <td>${u.age}</td>
  76. <td>${u.group.name}</td>
  77. </tr>
  78. </c:forEach>
  79. </c:otherwise>
  80. </c:choose>
  81. </table>
  82. <p>
  83. <li>测试循环控制标签c:forEach,varstatus</li><br>
  84. <tableborder="1">
  85. <tr>
  86. <td>姓名</td>
  87. <td>年龄</td>
  88. <td>所属组</td>
  89. </tr>
  90. <c:choose>
  91. <c:whentest="${emptyuserlist}">
  92. <tr>
  93. <tdcolspan="3">没有符合条件的数据!</td>
  94. </tr>
  95. </c:when>
  96. <c:otherwise>
  97. <c:forEachitems="${userlist}"var="user"varStatus="vs">
  98. <c:choose>
  99. <c:whentest="${vs.count%2==0}">
  100. <trbgcolor="red">
  101. </c:when>
  102. <c:otherwise>
  103. <tr>
  104. </c:otherwise>
  105. </c:choose>
  106. <td>
  107. <c:outvalue="${user.username}"/>
  108. </td>
  109. <td>
  110. <c:outvalue="${user.age}"/>
  111. </td>
  112. <td>
  113. <c:outvalue="${user.group.name}"/>
  114. </td>
  115. </tr>
  116. </c:forEach>
  117. </c:otherwise>
  118. </c:choose>
  119. </table>
  120. <p>
  121. <li>测试循环控制标签c:forEach,begin,end,step</li><br>
  122. <tableborder="1">
  123. <tr>
  124. <td>姓名</td>
  125. <td>年龄</td>
  126. <td>所属组</td>
  127. </tr>
  128. <c:choose>
  129. <c:whentest="${emptyuserlist}">
  130. <tr>
  131. <tdcolspan="3">没有符合条件的数据!</td>
  132. </tr>
  133. </c:when>
  134. <c:otherwise>
  135. <c:forEachitems="${userlist}"var="user"begin="2"end="8"step="2">
  136. <tr>
  137. <td>${user.username}</td>
  138. <td>${user.age}</td>
  139. <td>${user.group.name}</td>
  140. </tr>
  141. </c:forEach>
  142. </c:otherwise>
  143. </c:choose>
  144. </table>
  145. <p>
  146. <li>测试循环控制标签c:forEach,普通循环</li><br>
  147. <c:forEachbegin="1"end="10">
  148. a<br>
  149. </c:forEach>
  150. <p>
  151. <li>测试循环控制标签c:forEach,输出map</li><br>
  152. <c:forEachitems="${mapvalue}"var="v">
  153. ${v.key}=${v.value}<br>
  154. </c:forEach>
  155. <p>
  156. <li>测试循环控制标签c:forTokens</li><br>
  157. <c:forTokensitems="${strTokens}"delims=","var="v">
  158. ${v}<br>
  159. </c:forTokens>
  160. <p>
  161. <li>测试c:catch</li><br>
  162. <%
  163. try{
  164. Integer.parseInt("asdfsdf");
  165. }catch(Exceptione){
  166. out.println(e.getMessage());
  167. }
  168. %>
  169. <p>
  170. <c:catchvar="exinfo">
  171. <%
  172. Integer.parseInt("asdfsdf");
  173. %>
  174. </c:catch>
  175. ${exinfo}<br>
  176. <p>
  177. <li>测试c:import</li><br>
  178. <c:importurl="http://localhost:8080/struts_login"/>
  179. <p>
  180. <li>测试c:url和c:param</li><br>
  181. <c:urlvalue="http://localhost:8080/drp/sysmgr/user_add.jsp"var="v">
  182. <c:paramname="username"value="Jack"/>
  183. <c:paramname="age"value="20"/>
  184. </c:url>
  185. ${v}<br>
  186. <li>测试:redirect</li><br>
  187. <c:redirectcontext="/struts_login"url="/index.jsp"/>
  188. </html>

你可能感兴趣的:(C++,c,jsp,struts,C#)