One, c label
A "<c:out value=" ... "default=" ... "escapexml=" true ">
EscapeXML: Escapes the special symbol in value. If not specified as false, the default value is true.
Value: Output to values in the browser
Default value when the Default:value value is not found
Code
<c:out value= "Hello word! "/> <% Pagecontext.setattribute (" username "," Jack "); %> <br/> <c:out value=" ${username} "/&G T <BR/> <c:out value=" ${fdusername} "default = "Unknown"/> <br/> link: <c:out value= "< ; a href= ' # ' > Download </a> "escapexml=" false "/> <br/> link: <c : Out value= "<a href= ' # > Download </a>" escapexml= "true"/> <br/> Link: <c:out value= "<a href= ' # ' > Downloads </a>"/> <br/>
Two "<c:set var/value/scope/target/property>
var: there are 20% meanings. The variable name and the name of the domain object to be stored.
Target and property are for JavaBean.
Code
<c:set var= "name" value= "Jack" scope= "page"/> <c:out value= "${name}"/> <br/> <j Sp:usebean id= "User"class= "Com.suse.domain.User" scope= "page"/> <c:set target= "${user}" property= "UserName" value= "Jack"/> <c:out value= "${user.username}"/> <br/> <%Map<string, integer> map =NewHashmap<string, integer>(); Pagecontext.setattribute ("Map", map); %> <c:set target= "${map}" property= "Key" value= "Jack"/> <c:set target= "${map}" property = "value" value= "7000"/> <c:out value= "${map.key}"/> <br/> <c:out val Ue= "${map.value}"/>
Three "<c:remove/>
<c:remove var= "VarName" [scope= "{page|request|session|application}"]>
Code
<c:set var= "name" value= "Jack" scope= "page"/> default= "Unknown"/> <c:remove var= "name" Scope= "page"/> default= "Unknown"/>
Four "<c:catch var=" ... "
</c: Cath>
Code:
<c:catch var= "message" > <% int a = 10/0; %> </c:catch> default= "no exception!" "/>
Five "<c:if var/test/scope;
var: Saves the result of the Test property. True or False
scope: Saves the result of the test property to which domain object.
<c:if test= "${25>16}" var= "flag" scope= "request" > 25>16 </c:if> <jsp:forward page= "value.jsp"/>
Six "<c:choose>
<c:when test= "..." >
.....
</c:when>
<c:otherwise>
.....
</c:otherwise>
</c:choose>
**${param.age} Gets the value of the address bar parameter age
Code:
<c:choose> <c:when test= "${param.age >" > you're grown up </c:when> <c:o Therwise> You're still underage </c:otherwise> </c:choose>
seven "<c:foreach var/items/varstatus/begin/end/step>. </c:forEach>
var: Saves the currently iterated element to the page property name in this domain object
Items: The collection object to iterate on
varstatus: is a page domain object. Holds the information for this iteration.
Property: First: Whether it is a (true or false) Index: current subscript
Count : Count end: Is the last (true or false)
<% List new arraylist<string>(); List.add ( "Jack"); List.add ("Merry"); List.add ("Berry"); List.add ("Xixi"); List.add ( "Sisi"); Request.setattribute ("list", list); %> <c:foreach var= "item" items= "${list}" varstatus= "status" > -${item}-${ Status.first}-${status.last}-${status.count} <br/> </c:forEach>
JSP standard library label ——— c tag