首页 > 代码库 > jstl

jstl

1 选择分支

<!--非此即彼 分支--><c:choose>        <c:when test="${empty royalties}"> 0.00</c:when>        <c:otherwise>${royalties }</c:otherwise> </c:choose>

2 判断

<!--判断--><c:if test="${a.loginType==1 }">在线 </c:if><c:if test="${a.loginType==0 }"> <font color="blue">离线</font> </c:if>

3. 三目运算

<!--下拉列表(查询条件记忆)--><select name="transType" id="transType">        <option value="" ${shopCar.transType==null?‘selected=\"selected\"‘:‘‘ }>请选择</option>        <option value="1" ${shopCar.transType==1?‘selected=\"selected\"‘:‘‘ }>到付</option>        <option value="2" ${shopCar.transType==2?‘selected=\"selected\"‘:‘‘ }>免邮费</option></select>

 

<!--溢出字符自动截断 -->    <td>      ${fn:length(pr.req_remark)>21 ? fn:substring(pr.req_remark,0,21) : pr.req_remark}      ${fn:length(pr.req_remark)>21 ? ‘...‘ : ‘‘ }</td>

溢出截断也可以用<c:if>这么写:

<c:if test="${fn:length(article.title)>21"}>${fn:substring(article.title,0,21)}....</c:if><c:if test="${fn:length(article.title)<=21"}>${article.title}</c:if>

 

 

写作思想来自:http://www.cnblogs.com/Henry_zp/archive/2010/12/07/1899530.html

jstl