zoukankan      html  css  js  c++  java
  • jstl 与 el表达式

    jar下载地址参考:https://blog.csdn.net/qq_30062589/article/details/80224080

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
        <c:if test="${empty users }">
            aaa
        </c:if>
        <c:if test="${!empty users}">
            bbb
        </c:if>
        <br>
        <c:forEach begin="0" end="5" var="i">
            ${i }<br/>
        </c:forEach>
        <c:forEach items="${applicationScope.users }" var="user">
            ${user.name }<br/>
        </c:forEach>
    </body>
    </html>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        <%@ page import="cn.sasa.domain.*" %>
        <%@ page import="java.util.*" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
        <% 
            request.setAttribute("name", "hi");
            
            MyUser user1 = new MyUser();
            user1.setName("aaa");
            session.setAttribute("user", user1);
            
            MyUser user2 = new MyUser();
            user2.setName("bbb");
            List<MyUser> userList = new ArrayList<MyUser>();
            userList.add(user1);
            userList.add(user2);
            application.setAttribute("users", userList);
            
            out.write("web----"+this.getServletContext().getContextPath());
        %>
        <!-- el表达式从域中取值取值 -->
        <br/>
        ${ requestScope.name }
        <br/>
        ${sessionScope.user.name }
        <br/>
        ${applicationScope.users[0].name }
        ${applicationScope.users[1].name }
        
        <hr/>
        <!-- *全域查找 -->
        <br/>
        ${ name }
        <br/>
        ${user.name }
        <br/>
        ${users[0].name }
        ${users[1].name }
        <br/>
        el_web_-----${pageContext.request.contextPath }
        
    </body>
    </html>
  • 相关阅读:
    React 源码剖析系列 - 生命周期的管理艺术
    大数据浪潮下的前端工程师
    win7 秘钥
    Immutable 详解及 React 中实践
    js 设置日期函数
    node 一站式 学习 教程
    Python_如何定义带参数的装饰器?
    Python-装饰器中保留被装饰函数元数据
    Python-用装饰器实现递归剪枝
    Python-通过实例方法调用-统一接口的实现-getter methodcaller
  • 原文地址:https://www.cnblogs.com/SasaL/p/10635180.html
Copyright © 2011-2022 走看看