1.抓取url中的id值
例如: http://localhost:8080/qas/delete_question.html?qid=4
<
input type
=
"
hidden
"
name
=
"
qid
"
value
=
"
${param.qid}
"
/>
2.选定默认radio
<
s:iterator value
=
"
satisfctions
"
>
< td >
< input name = " satify_id " type = " radio " < s: if test = " ${question.satisfaction.id==id} " > checked </ s: if > value = " <s:property value= " id " /> " >< s:property value = " name " /></ input >
</ td >
</ s:iterator >
< td >
< input name = " satify_id " type = " radio " < s: if test = " ${question.satisfaction.id==id} " > checked </ s: if > value = " <s:property value= " id " /> " >< s:property value = " name " /></ input >
</ td >
</ s:iterator >
3. 逻辑标签
<
c:
if
test
=
"
${msg!='没有查到该用户'}
"
>
< tr >
< td colspan = " 2 " align = " center " >< input type = " submit " onclick = " return isRemit(); " value = " 确定 " /></ td >
</ tr >
< tr >
< td colspan = " 2 " align = " center " >< input type = " submit " onclick = " return isRemit(); " value = " 确定 " /></ td >
</ tr >
注意要加单引号'',因为标签取出的东东都是字符串。
</ c: if >
</ c: if >
<c:if test="${realAnswer== '1 '}" >是 </c:if >
<c:if test="${realAnswer== '2 '}" >不是 </c:if >
<c:if test="${realAnswer!= '1 ' && realAnswer!= '2 '}" >${realAnswer}
<c:if test="${realAnswer== '2 '}" >不是 </c:if >
<c:if test="${realAnswer!= '1 ' && realAnswer!= '2 '}" >${realAnswer}
</c:if >
4.得到项目根目录。
$
...
{pageContext.request.contextPath}
< script language = " javascript " src = " ${pageContext.request.contextPath}/prototype.js " ></ script >
< script language = " javascript " src = " ${pageContext.request.contextPath}/prototype.js " ></ script >
5.遍历
<
c:forEach var
=
"
coursePart
"
items
=
"
${courseParts}
"
>
< tr class = " tablehead " >
< td > $ ... {coursePart.id} </ td >
< td > $ ... {coursePart.name} </ td >
< td > $ ... {coursePart.course.name} </ td >
< td >
< a href = " increaseDown.html?coursePartId=${coursePart.id} " > 下载 </ a >
</ td >
< td >
< a href = " increaseHitsOnline.html?coursePartId=${coursePart.id} " > 查看 </ a >
</ td >
</ tr >
</ c:forEach >
< tr class = " tablehead " >
< td > $ ... {coursePart.id} </ td >
< td > $ ... {coursePart.name} </ td >
< td > $ ... {coursePart.course.name} </ td >
< td >
< a href = " increaseDown.html?coursePartId=${coursePart.id} " > 下载 </ a >
</ td >
< td >
< a href = " increaseHitsOnline.html?coursePartId=${coursePart.id} " > 查看 </ a >
</ td >
</ tr >
</ c:forEach >
6.判断为null
<
c:
if
test
=
"
${question.answer!=null}
"
>
$
...
{question.answer}
</
c:
if
>
7.带序号遍历
<
c:forEach var
=
"
subject
"
items
=
"
${subjects}
"
varStatus
=
"
i
"
>
< a href = " # " onclick = " link_clicked('${i.index}') " > $ ... {subject.name} </ a > |
</ c:forEach >
< a href = " # " onclick = " link_clicked('${i.index}') " > $ ... {subject.name} </ a > |
</ c:forEach >
8.嵌套遍历
<
c:forEach var
=
"
subject
"
items
=
"
${subjects}
"
varStatus
=
"
i
"
>
< div id = " sub_nav${i.index} " class = " head-sub-nav " style = " display: none; " >
< c:forEach var = " book " items = " ${subject.books} " varStatus = " j " >
< a href = " # " onclick = " link_clicked2(${i.index},${j.index}); " > $ ... {book.name} </ a > |
</ c:forEach >
</ div >
</ c:forEach >
< div id = " sub_nav${i.index} " class = " head-sub-nav " style = " display: none; " >
< c:forEach var = " book " items = " ${subject.books} " varStatus = " j " >
< a href = " # " onclick = " link_clicked2(${i.index},${j.index}); " > $ ... {book.name} </ a > |
</ c:forEach >
</ div >
</ c:forEach >
9.forEach与set混合应用
<
td
>
< c: set var = " isRightNum " value = " 0 " />
< c:forEach var = " questionHistory " items = " ${examnationHistory.questionsHistorys} " >
< c: if test = " ${questionHistory.isRight == 0} " >
< c: set var = " isRightNum " value = " ${isRightNum +1} " />
</ c: if >
</ c:forEach >
$ ... {isRightNum } 个
</ td >
< c: set var = " isRightNum " value = " 0 " />
< c:forEach var = " questionHistory " items = " ${examnationHistory.questionsHistorys} " >
< c: if test = " ${questionHistory.isRight == 0} " >
< c: set var = " isRightNum " value = " ${isRightNum +1} " />
</ c: if >
</ c:forEach >
$ ... {isRightNum } 个
</ td >
10.截取字符串
${fn:substring(cityDay.date,"0","10")}
11. 嵌套循环,例如遍历树形结构,
其中
页面遍历