-
Notifications
You must be signed in to change notification settings - Fork 3
BaseSyntax
jindw edited this page Nov 27, 2016
·
3 revisions
##Variable / Expression output
Example:
${user.name}。
Description:
The expression value automatically encoding html/xml special characters base on HTML/XML semantic context and safety output.
##Conditional Tag Example:
<c:if test="${index == 0}">first index</c:if>
<c:else test="${index != end}">index:${index}</c:else>
<c:else>end index</c:else>
##Loop Tag Example:
<c:for var="item" list="${list}">
${for.index}:${item}.
</c:for>
<c:else>no record available!!</c:else>
##Variable Declaration Tag
Example1:(via value expression)
<c:var name="myName" value="${user.name}" />
Example2:(via child nodes)
<c:var name="myName" >
${user.firstName} ${user.lastName}
</c:var>
Example:
<!-- function dec -->
<c:def name="genRow(user)">
<tr>
<td>${user.name}</td>
<td>${user.city}</td>
</tr>
</c:def>
<!-- function usage -->
<table>
<c:for var="user" list="${users}">
$!{genRow(user)}
</c:for>
</table>
Example1: (Full file include)
<c:include path="test.tpl"/>
Example2: (partly file include by css3)
<!--select h2 which ID=content and the next p node -->
<c:include path="test.tpl" selector="h2[id='content'],h2[id='content']>p"/>
Example2: (partly file include by xpath)
<c:include path="test.tpl" xpath="body/*"/>
##Template Extends Tag Example1:
<!-- the current.html -->
<c:extends path="parent.xhtml">
<c:block name="title">Real Title</c:block>
<c:block name="content">New Content...</c:block>
</c:extends>
<!-- the parent.html -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><c:block name="title"/></title>
</head>
<body>
<div id="head">The Shared header</div>
<div id="content"><c:block name="content">the default content...</c:block></div>
<div id="foot">The Shared footer</div>
</body>
</html>