1、el表达式可以应用到jsp页面的脚本中,而不能在js脚本中:
<script type="text/javascript">
var s = "${systemModelId }"; //在javascript中可以通过获取el表达式的值
</script>
2、通过el表达式循环对象时,如果是单个对象可以用null来判断是否为空,如果是List等集合要判断为空可以用字符串 "[]"来判断:
<c:if test="${delivery.goods=='[]'}">为空</c:if>
<c:if test="${person.card==null}">为空</c:if>
3、el表达式函数应用:
引入jstl函数标签库:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
length函数 : <c:if test="${fn:length(delivery.remark)<10}">${delivery.remark }</c:if>
4、jstl标签和struts标签结合使用:
<s:iterator value="#request.pageInfo.list" var="delivery"> <tr> <td class="checkboxTd hide"><input type="checkbox" class="checkbox" name="checklistdelivery"></td> <td class="code hide">${delivery.code}</td> <td>${delivery.layer }</td> <td> <div title="<c:forEach items="${delivery.goods}" var="good">${good.name} </c:forEach>"> <c:forEach items="${delivery.goods}" var="good" begin="0" end="0"> ${good.name} ... </c:forEach> </div> </td> <td>${delivery.weight }</td> <td><s:property value="#delivery.containers.size()" /></td> <td>
<c:if test="${delivery.rebate==1 }"> 无特殊情况 </c:if> <td>${delivery.amountReceivable }</td> <td> <div title="${delivery.remark }"> <c:if test="${fn:length(delivery.remark)<10}">${delivery.remark }</c:if> <c:if test="${fn:length(delivery.remark)>=10}">${fn:substring(delivery.remark, 0,10)}... </c:if> </div> </td> </tr> </s:iterator>