JSTL表达式在项目中的使用
2015-05-05 14:25
197 查看
<td class="text-center">
<c:choose>
<c:when test="${device.status == 1 }">InActive</c:when>
<c:when test="${device.status==0 }">Active</c:when>
<c:otherwise></c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="device.crtTime==device.minTime">New Created</c:when>
<c:when test="${device.status==1&&device.crtTime==device.maxTime }">Logout</c:when>
<c:otherwise>Modify</c:otherwise>
</c:choose>
</td>
<c:forEach items="${modalities}" var="m">
<option value="${m.key}"><c:out value="${m.value}" /></option>
</c:forEach>
<fmt:formatDate value="${item.createDate}" pattern="yyyy-MM-dd"/></td>
<select name="year" id="year">
<c:forEach var="ye" items="${years}" varStatus="vs">
<c:if test="${ye==year}">
<option value="${ye}" selected=selected>${ye}</option>
</c:if>
<c:if test="${ye!=year}">
<option value="${ye}">${ye}</option>
</c:if>
</c:forEach>
</select>
JSTL截取字符串
jstl1.1引入了一个fn.tld的标签,用于处理字符,如获得字符length,substring,indexof,endWith,lowcase
实现截取字符串
<c:set var="log.logTitle" value="做一个截取字符串长度的测试"
<c:choose>
<c:when test="${fn:length(log.logTitle) > 10}">
<c:out value="${fn:substring(log.logTitle, 0, 10)}......" />
</c:when>
<c:otherwise>
<c:out value="${log.logTitle}" />
</c:otherwise>
</c:choose>
JSTL获取map的值
<c:forEach var="delivery" items="${deliveryMap}">
<option value='<c:out value="${delivery.key }"></c:out>'><c:out value="${delivery.value }"></c:out></option>
</c:forEach>
jstl做判断
<c:choose>
<c:when test="${editItem.status==0}">
<option value="0" selected="selected">Active</option>
</c:when>
<c:otherwise>
<option value="0">Inactive</option>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${editItem.status==1}">
<option value="1" selected="selected">Inactive</option>
</c:when>
<c:otherwise>
<option value="1">Inactive</option>
</c:otherwise>
</c:choose>
<c:forEach items="${labs }" var="lab">
<option value="${lab.locationid }" <c:if test="${ editItem.labId !=null&&lab.locationid eq editItem.labId }">selected=selected </c:if> > ${lab.labName}</option>
</c:forEach>
<td class="middle_title takeOff">
<select name="takeOff" id="takeOff" style="width:80%">
<c:forEach var="takeOfforder" items="${order.allTakeOff}">
<option value="${takeOfforder.key}" <c:if test="${takeOfforder.value eq order.takeOff}">selected="selected"</c:if>>${takeOfforder.value}</option>
</c:forEach>
</select>
</td>
<c:choose>
<c:when test="${device.status == 1 }">InActive</c:when>
<c:when test="${device.status==0 }">Active</c:when>
<c:otherwise></c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="device.crtTime==device.minTime">New Created</c:when>
<c:when test="${device.status==1&&device.crtTime==device.maxTime }">Logout</c:when>
<c:otherwise>Modify</c:otherwise>
</c:choose>
</td>
<c:forEach items="${modalities}" var="m">
<option value="${m.key}"><c:out value="${m.value}" /></option>
</c:forEach>
<fmt:formatDate value="${item.createDate}" pattern="yyyy-MM-dd"/></td>
<select name="year" id="year">
<c:forEach var="ye" items="${years}" varStatus="vs">
<c:if test="${ye==year}">
<option value="${ye}" selected=selected>${ye}</option>
</c:if>
<c:if test="${ye!=year}">
<option value="${ye}">${ye}</option>
</c:if>
</c:forEach>
</select>
JSTL截取字符串
jstl1.1引入了一个fn.tld的标签,用于处理字符,如获得字符length,substring,indexof,endWith,lowcase
实现截取字符串
<c:set var="log.logTitle" value="做一个截取字符串长度的测试"
<c:choose>
<c:when test="${fn:length(log.logTitle) > 10}">
<c:out value="${fn:substring(log.logTitle, 0, 10)}......" />
</c:when>
<c:otherwise>
<c:out value="${log.logTitle}" />
</c:otherwise>
</c:choose>
JSTL获取map的值
<c:forEach var="delivery" items="${deliveryMap}">
<option value='<c:out value="${delivery.key }"></c:out>'><c:out value="${delivery.value }"></c:out></option>
</c:forEach>
jstl做判断
<c:choose>
<c:when test="${editItem.status==0}">
<option value="0" selected="selected">Active</option>
</c:when>
<c:otherwise>
<option value="0">Inactive</option>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${editItem.status==1}">
<option value="1" selected="selected">Inactive</option>
</c:when>
<c:otherwise>
<option value="1">Inactive</option>
</c:otherwise>
</c:choose>
<c:forEach items="${labs }" var="lab">
<option value="${lab.locationid }" <c:if test="${ editItem.labId !=null&&lab.locationid eq editItem.labId }">selected=selected </c:if> > ${lab.labName}</option>
</c:forEach>
<td class="middle_title takeOff">
<select name="takeOff" id="takeOff" style="width:80%">
<c:forEach var="takeOfforder" items="${order.allTakeOff}">
<option value="${takeOfforder.key}" <c:if test="${takeOfforder.value eq order.takeOff}">selected="selected"</c:if>>${takeOfforder.value}</option>
</c:forEach>
</select>
</td>
相关文章推荐
- idea下Maven项目的webapp下的jsp页面无法使用el或者jstl表达式
- 项目中jSTL的使用
- jstl表达式使用介绍
- maven 项目中使用 jstl标签
- 使用jstl表达式的问题
- java web简易网上书店项目系列,使用MVC模式(servlet+jstl+dbutils),开篇
- 项目中list、String和正则表达式的的一些使用
- 实际项目开发中需要的格式化标签以及JSTL标签库介绍【1核心标签(用得最多)2 国际化标签(I18N格式化标签) 数据库标签(SQL标签,很少使用) XML标签(几乎不用) JSTL函数(EL函数)】
- Maven项目下使用JSTL需导入的依赖
- MAVEN项目中JSP页面使用JSTL标签
- .NET平台开源项目速览(8)Expression Evaluator表达式计算组件使用
- .NET平台开源项目速览(8)Expression Evaluator表达式计算组件使用
- maven 项目中使用 jstl标签
- Web项目中使用JSTL标签问题
- JSTL中fn表达式的使用说明
- 【Android】在android中使用lamdba表达式,gradle-retrolamdba开源项目使用---尝试未果,有待解决
- 关于JSTL表达式中function函数的使用
- 正则表达式在项目中的使用和小结
- 正则表达式使用总结--记录项目中遇到的自己未解决的正则
- java默认语法、EL、JSTL表达式,JSTL和struts Tag标签的使用总结