JSTL1.1的几中常用使用方法

来源:互联网 发布:sql in用法? 编辑:程序博客网 时间:2024/05/21 14:44
 1:判断List当中是否包含当前值:
    yxmkList是 moduleId 的List
    <c:if test="${fn:contains(yxmkList, one.moduleId)}">checked="checked"</c:if>

 2:使用 sessionScope 变量的 EL 表达式

<%request.getSession().setAttribute("sampleValue", new Integer(10));%>

${sessionScope.sampleValue}

 3:截取字符串
 :
  <c:set var="log.logTitle"value="做一个截取字符串长度的测试"
    <c:choose>
       <c:whentest="${fn:length(log.logTitle) >10}">
       <c:outvalue="${fn:substring(log.logTitle, 0, 10)}......"/>
     </c:when>
     <c:otherwise>
       <c:outvalue="${log.logTitle}" />
     </c:otherwise>
   </c:choose>     
原创粉丝点击