• JSP中常用的的EL表达式的汇总


    Jsp基础知识

    • jsp的组成

      1. html静态页面(css、javascript)
      2. java代码 <% %> (_jspService方法中)
      3. 内置对象 out request
      4. 表达式 <%= %>
      5. 声明方法和成员变量 <%! %>
      6. 指令 %@page %@include
      7. 动作 jsp:include jsp:forward
      8. 注释 <%-- --%>
    • 包含关系

      • 静态包含 <%@include file="footer.jsp" %>
      • 动态包含 <jsp:includ e page="header.jsp">
    • 静态包含和动态包含的区别

       原理是否生产java文件是否生可以有同名变量包含的时机
      动态包含 方法的调用 生成 可以 执行class文件
      静态包含 内容嵌套 不生成 不可以 转译

    EL表达式

    • jar的引用

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    • 常用语法

      • for循环

        <c:forEach items="${recommendList}" var="item">
            ${item.desc}
        </c:forEach>
        <!--利用下标取出前四个元素 status-->
        <c:forEach items="${split}" var="subString" varStatus="status">
            <c:if test="${status.index < 4}">
                <li class=""><img src="${baseUrl}${subString}" alt="用户配图丢失">
            </c:if>
        </c:forEach>
        <!-- 取出123 -->
        <c:forEach var="x" begin="1" end="${pageProductHot.extra.listPageCount}">
            <a href="${baseUrl}product/jsp/indexForH5.jsp">${x}</a>
        </c:forEach>
      • if判断

        <!--取出前五个元素 -->
        <c:forEach items="${pageProductHot.list}" var="item" varStatus="status">
        <c:if test="${(status.index) < 5}">
            ${item.name}
        </c:if>   
        </c:forEach>
        <!--判断字符串是否为“” 判断是否为null-->
        <c:if test="${not empty item.coverImgUrl || item.coverImgUrl eq null}">
        
        </c:if>
        <!--分割字符串 并且判断字符串长度-->
        <c:set value="${fn:split(item.imgUrls, ',') }" var="split" />
            <c:if test="${fn:length('${split}') == 1}"
            <img src="${baseUrl}${split[0]}">
            
            <c:if test="${fn:length(item.textContentShort) > 100}">
            </c:if>
        </c:if>
      • split分割字符串

        <!--分割字符串 得到字符串数组-->
        <c:set value="${fn:split(item.imgUrls, ',') }" var="split" />
      • replace替换字符串中的内容

        <c:set var="newLine" value="
        " />
        ${fn:replace(product.loanRequire, newLine, "<br />")}

         

  • 相关阅读:
    Delphi中TFlowPanel实现滚动条效果
    Delphi组件开发-在窗体标题栏添加按钮(使用MakeObjectInstance(NewWndProc),并处理好多消息)
    减小Delphi的Exe文件大小(11种方法)
    画出太极图
    类似地图的以鼠标为中心缩放图像
    andoid x项目的优化 1
    ICON图标文件解析
    所有语言的Awesome(2)
    获取EIP(汇编语言直接给Delphi变量赋值)
    Qt Windows下链接子系统与入口函数(终结版)(可同时存在main和WinMain函数)
  • 原文地址:https://www.cnblogs.com/tujietg/p/10767664.html
Copyright © 2020-2023  润新知