<c:forTokens>
<c:forTokens items="stringOfTokens" delims="delimiters"
[var="varName"]
[varStatus="varStatusName"]
[begin="begin"] [end="end"] [step="step"]>
body content
</c:forTokens>
参数说明:
Items:要输出的变量
Delims:以什么为分隔符
Var:保存每次循环出的变量
如:
//测试c:forTokens request.setAttribute("strTokens", "1,2,3,4,5,6");
<c:forTokens items="${strTokens}" delims="," var="v"> ${v } </c:forTokens>
以上以 , 为分隔符将变量循环输出
URL Related Actions
<c:import>
Syntax 1: Resource content inlined or exported as a String object
<c:import url=”url” [context=”context”]
[var=”varName”] [scope=”{page|request|session|application}”]
[charEncoding=”charEncoding”]>
optional body content for <c:param> subtags
</c:import>
Syntax 2: Resource content exported as a Reader object
<c:import url=”url” [context=”context”]
varReader=”varReaderName”
[charEncoding=”charEncoding”]>
body content where varReader is consumed by another action
</c:import>
参数说明:
Context:指定工程路径
url:精确到页面
如:
<li>测试c:import</li><br> <c:import url="http://localhost:8080/struts_login/index.jsp"/> <p>
直接在URL上指定精确页面也是可以的,但这样就写死了代码
<c:url>
Syntax 1: Without body content
<c:url value=”value” [context=”context”]
[var=”varName”] [scope=”{page|request|session|application}”]/>
Syntax 2: With body content to specify query string parameters
<c:url value=”value” [context=”context”]
[var=”varName”] [scope=”{page|request|session|application}”]>
<c:param> subtags
</c:url>
Value:要提交参数的页面
Var:最后组成的URL
如:
<c:url value="http://localhost:8080/drp/sysmgr/user_add.jsp" var="v"> <c:param name="username" value="Jack"/> <c:param name="age" value="20"/> </c:url> ${v }
最后组成了一个URL,可以看输出
<c:param>
Syntax 1: Parameter value specified in attribute “value”
<c:param name=”name” value=”value”/>
Syntax 2: Parameter value specified in the body content
<c:param name=”name”>
parameter value
</c:param>
<c:redirect>
Syntax 1: Without body content
<c:redirect url=”value” [context=”context”]/>
Syntax 2: With body content to specify query string parameters
<c:redirect url=”value” [context=”context”]/>
<c:param> subtags
</c:redirect>
标签说明:页面将重定向到一个新页面,重定向时还可以传递参数过去
Formatting Actions
<fmt:parseDate>
Syntax 1: without a body
<fmt:parseDate value=”dateString”
[type=”{time|date|both}”]
[dateStyle=”{default|short|medium|long|full}”]
[timeStyle=”{default|short|medium|long|full}”]
[pattern=”customPattern”]
[timeZone=”timeZone”]
[parseLocale=”parseLocale”]
[var=”varName”]
[scope=”{page|request|session|application}”]/>
Syntax 2: with a body to specify the date value to be parsed
<fmt:parseDate [type=”{time|date|both}”]
[dateStyle=”{default|short|medium|long|full}”]
[timeStyle=”{default|short|medium|long|full}”]
[pattern=”customPattern”]
[timeZone=”timeZone”]
[parseLocale=”parseLocale”]
[var=”varName”]
[scope=”{page|request|session|application}”]>
date value to be parsed
</fmt:parseDate>
参数说明:
Value:要格式化的值
Type:显示类型,如只显示时间,只显示日期
dateStyle:日期的显示类型
timeStyle:时间的显示类型
pattern:怎样显示格式化后的日期,直接设置该属性即可
如:
<fmt:formatDate value="${today}"/> <fmt:formatDate value="${today}" type="date"/> <fmt:formatDate value="${today}" type="time"/> <fmt:formatDate value="${today}" type="both"/> <fmt:formatDate value="${today}" dateStyle="short"/> <fmt:formatDate value="${today}" dateStyle="medium"/> <fmt:formatDate value="${today}" dateStyle="long"/> <fmt:formatDate value="${today}" dateStyle="full"/> <fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss"/> <fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" var="d"/> ${d }
如果设置了保存的变量值就不会在直接显示了