Lir

JSTL

Lir
Feb 29th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. Должны быть библиотеки jstl.jar и standart.jar лежат где-то тут C:\apache-tomcat-6.0.16\webapps\examples\WEB-INF\lib
  2. //Декларация
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  4.  
  5. //Вывод
  6. <c:out value="${user.login}'s blog" default="guest"/>
  7.  
  8. //Цикл
  9. <c:forEach var="message" items="${messagesList}">
  10.         <b>${message.title}</b>
  11.         ${mine:parseDate(message.date)}<Br>
  12.         ${message.content}<Br><Br>
  13. </c:forEach>
  14.  
  15. //if
  16. <c:if test=”${userType eq ‘member’ }>
  17.     <jsp:include page=”inputComments.jsp/>
  18. </c:if>
  19.  
  20. //When-otherwise
  21. <c:choose>
  22.     <c:when test=”${userPref == ‘performance’}>
  23.         Now you can stop even if you <em>do</em> drive insanely fast.
  24.     </c:when>
  25.     <c:when test=”${userPref == ‘safety’}>
  26.         Our brakes will never lock up, no matter how bad a driver you are.
  27.     </c:when>
  28.     <c:when test=”${userPref == ‘maintenance’}>
  29.         Lost your tech job? No problem--you won’t have to service these brakes
  30.         for at least three years.
  31.     </c:when>
  32.     <c:otherwise>
  33.         Our brakes are the best.
  34.     </c:otherwise>
  35. </c:choose>
  36.  
  37. //Set
  38. <c:set var=”userLevel” scope=”session” value=”Cowboy” /> - значение переменной
  39. <c:set target=”${PetMap}” property=”dogName” value=”Clover” /> - JavaBean или Map
  40.  
  41. //Удаялем переменную
  42. <c:remove var=”userStatus” scope=”request” />
  43.  
  44. //Импорт и передача параметра
  45. <c:import url=”Header.jsp>
  46.     <c:param name=”subTitle” value=”We take the sting out of SOAP.” />
  47. </c:import>
Advertisement
Add Comment
Please, Sign In to add comment