• jstl_core标签库


    先导入这个

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

    1

    <c:out>输出标签  value代表输出

    <c:out value="${param.action }"></c:out>

    2

    <c:if>标签 test代表判断值

    <c:if test="${param.action=='dd'}">
    <c:out value="${param.text }"></c:out>
    </c:if>

    <c:set var="salary" scope="session" value="${2000*2}"/>
    <c:if test="${salary > 1}">

    3

    choose ,otherwise

    <c:choose>
    <c:when test="${param.text >3}">
    when<br>
    </c:when>
    <c:otherwise>
    otherwise
    </c:otherwise>
    </c:choose>

    4

    var定义变量,begin初始值,end结束条件,step控制步长

    <c:forEach var="number" begin='2' end='100' step='2'>
    <div>${number }</div>
    </c:forEach>

    5

    list循环,items=${personList} var="person"

    <c:forEach  items="${personList }" var="person">

    辅助代码

        List<Person> personList = new ArrayList<Person>();
        Person person1 = new Person();
        person1.setName("huanggabin");
        person1.setAge(2);
        Person person2 = new Person();
        person2.setName("xiaoming");
        person2.setAge(2);
        personList.add(person1);
        personList.add(person2);
        request.setAttribute("personList",personList);//一定要加,保存到request中
    View Code

     6

    set标签,var 定义变量,value设置属性值,scope设置范围,target设置对象,(就是var 和target互补吧

    然后有了target同时要出现property,使用set可以代替,<jsp:bean><jsp:setProperty> (当然在request添加了这个对象

        <c:if test="$param.name != null">
            <c:set target="${person }" property="name" value="${param.name }"></c:set>
            ${person.name}
            <c:set target="${person }" property="age" value="${param.age }"></c:set>
            ${person.age}
        </c:if>

    7

    <c:catch var ="catchException">
       <% int x = 5/0;%>
    </c:catch>
    
    <c:if test = "${catchException != null}">
       <p>The exception is : ${catchException} <br />
       There is an exception: ${catchException.message}</p>
    </c:if>

    8

    <c:redirect url="http://www.baidu.com">
        <c:param name="people" value="huanggabin"></c:param>
    </c:redirect>
  • 相关阅读:
    pwd命令
    python-windows环境安装
    python介绍
    elk安装
    elk介绍
    111
    使用CEF作为用户界面
    使用CEF作为浏览器
    c# 内嵌chrome(Webkit)
    待搞清楚
  • 原文地址:https://www.cnblogs.com/vhyc/p/6562053.html
Copyright © 2020-2023  润新知