<body>
<%
Request.setattribute ("name", "lisi123");
Request.setattribute ("TTT", New ArrayList ());
Request.setattribute ("template", "%>
<!--
Value: The values to display
EscapeXML: Whether to translate HTML tags true|false
Default: Defaults worth value is null when displaying default values can also be written between label bodies the contents of the default and tag bodies cannot be present at the same time
Note: The most common way is the EL expression
-
<c:out value= "${ttt}" Escapexml= "false" >123</c:out><br>
${template}
${empty TTT}
<!--
In El expression + denotes the meaning of sums
-
${"1" + "2"}
<%--${"A" + "B"}--%>
</body>
TESTSET.JSP:
<body>
<%!
public static Class users{
private String name;
Public String GetName () {
return this.name;
}
public void SetName (String name) {
THIS.name = name;
}
}
%>
<!--
Scope: If not specified, default to the scope given in the page scope without a scope end
Value: The values stored
var: the stored variable
Target: The object to change
Property: The attribute in the object that you want to change
Common ways
Value+var+scope
Value+target+property
-
<%
Users u = new users ();
U.setname ("Zhangsan");
Request.setattribute ("User", u);
%>
<crazy:set scope= "Request" value= "testset123" var= "Testset" ></crazy:set>
<crazy:set scope= "page" value= "testset123456" var= "Testset" ></crazy:set>
${requestscope.testset}
${user.name}
<crazy:set property= "name" value= "Lisi" target= "${user}" ></crazy:set>
${user.name}
<!--
If you do not specify a scope, the value of the corresponding name in all scopes is removed
-
<crazy:remove var= "Testset" scope= "page"/>
${testset}
</body>
TESTIF.JSP:
<body>
<c:set value= "one" var= "num" scope= "request" ></c:set>
<c:if test= "${param.num>10}" var= "Flag" scope= "page" >
<H1 style= "color:red" >num greater than 10</c:if>
<c:if test= "${!flag}" >
<H1 style= "Color:green" >num not much more than 10</c:if>
<!--
if () {
}else if () {
}else{
}
else{
}if () {
}else{
}else[
}
-
<c:choose>
<c:when test= "${param.num>10 && param.num<20}" >
<c:when test= "${param.num>20 && param.num<50}" >
<c:when test= "${param.num<10}" >
<C:OTHERWISE><H1 style= "color:red" >num > 50</c:choose>
</body>
TESTFOREACH.JSP:
<body>
<%
list<string> list = new arraylist<string> ();
for (int i=0;i<20;i++) {
List.add ("list" +i);
}
Request.setattribute ("list", list);
%>
<!--
Foreach
Items: Collections to loop
var: variable for each time of the loop
Step: Stepper or interval
Begin: From which subscript element begins
End: at which subscript element ends
-
<c:foreach items= "${list}" var= "L" step= "2" begin= "0" end= "ten" varstatus= "S" >
<span>${l}</span>|:| <span>${s.current}|${s.index}|${s.count}|${s.first}|${s.last}</span><br>
</c:forEach>
</body>
Basic use of Jstl