Document directory
- <C: Out>
- C: Set
- C: Remove
- C: Catch
- C: If
- C: foreach
- C: fortokens
- C: URL
- C: Import
- Job:
Jstl -- core tag <C: Out>
<C: Out value = "$ {psw}" escapexml = "$ {user! = NULL} "> cccccccccccc </C: Out> |
C: Set
<C: set var = "user" value = "Tom" scope = "page"/> <C: out value = "$ {user}"> </c: out> <% Map map = new HashMap (); Request. setAttribute ("map", map ); %> <C: set property = "city" value = "baoding" target = "$ {map}"/> <Br/> <C: out value = "$ {map. city}"> </c: out> <Br/> <% Person p = new Person (); Request. setAttribute ("person", p ); %> <C: set property = "name" value = "Susan" target = "$ {person}"/> <C: out value = "$ {person. name}"/> |
C: Remove
<% Session. setAttribute ("date", "2011 "); %> $ {Date} <C: remove var = "date" scope = "session"/> <C: out value = "$ {date}"> date is deleted </c: out> |
C: Catch
<C: catch var = "myexception"> <% Int I = 3/0; %> </C: catch> Output exception <C: out value = "$ {myexception}"> </c: out> <Br/> Exception: <C: out value = "$ {myexception. message}"/> <br/> Stack track <C: out value = "$ {myexception. stackTrace}"/> <br/> |
C: If
<C: if test = "$ {date = null}" var = "result" scope = "page"> The $ {result} expression is valid. </C: if> |
C: foreach
C: fortokens
<C: forTokens items = "abc efg, xy| 333" delims = ", y |" var = "item"> <C: out value = "$ {item}"/> <br/> </C: forTokens> |
C: URL
1.
<C: url value = "tableDemo. jsp" var = "tablePageUrl"> </c: url> <A href = "$ {tablePageUrl}"> tableDemo </a> |
2.
<! -- To Prevent Users From disabling cookies, the url tag transmits the session id as a parameter during the first access, As follows: <A href = "tableDemo. jsp; jsessionid = 4AA1BCFF81E84329D15E98E3E8DC95F6"> tableDemo </a> However, if you try again and find that you are allowed to use cookies, the session id will not be passed. For example: <A href = "tableDemo. jsp"> tableDemo </a> |
------------------------------------------------------------------
3.
<Br/> If the url tag does not have the var attribute, the value is returned to the page and tableDemo. jsp is output. <br/> <C: url value = "tableDemo. jsp"/> <Br/> and if the first character of the value is '/', the project name is automatically added as its prefix and the output is/JSTL_Test/tableDemo. jsp. <br/> <C: url value = "/tableDemo. jsp"/> <Br/> <! -- The following code runs the result of <a href = "/JSTL_Test/tableDemo. jsp"> tableDemo </a> --> <A href = "<c: url value ="/tableDemo. jsp "/>"> tableDemo </a> |
4.
<! -- The url tag can be embedded with the param tag to pass the value, and the url encoding can be performed automatically if the value is Chinese. --> <C: url value = "tableDemo. jsp" var = "table"> <C: param name = "city"> Baoding </c: param> </C: url> <A href = "$ {table}"> tableD </a> |
C: Import
<C: Import url = "http://www.ifeng.com"> </C: Import>
Job:
Use the jstl label to implement the jiujiu multiplication rule table and display the table (set the interval color of the table)