Usage of JSTL

JSTL out usage

<h1>Use of JSTL core library</h1>

<c:out value="${'JSTL' }"></c:out>

<hr>
<!-- If the value to be output is empty, the only difference is that the default value can be set later -->
<c:out value="${name }" default="unknow"></c:out>

<hr>

<c:out value="${'<font color=red>liang</font>' }" ></c:out>

<!--
	The default output is:
	<font color=red>liang</font>
 -->
 
 <br>
<c:out value="${'<font color=red>liang</font>' }"  escapeXml="false"></c:out>

<!--
	Such output is the parsed html code: red liang
 -->

If you use the method of ${}: you cannot directly output the form of the source code, but the parsed HTML form that is directly output

${'<font color=red>liang</font>' }

<c:out value="${'<font color=red>liang</font>' }"  escapeXml="false"></c:out>

The output of both codes is the same:

liang

all red liang

JSTL's set usage:

<h1>Use of JSTL core library</h1>

<!-- Create person object -->

<jsp:useBean id="person" class="cn.wgg.jsp.Person"></jsp:useBean>

<!-- Assignment-->
target is the reference object property is the property of the object, value is the value
<c:set target="${person }" property="name" value="jkl"></c:set>
<c:set target="${person }" property="age" value="10"></c:set>
<c:set target="${person }" property="ID" value="1"></c:set>
print object
<c:out value="${person }"></c:out>



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325931795&siteId=291194637