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>
  • 相关阅读:
    jmeter中设置线程数与设置集合点的区别
    在linux系统中如何通过shell脚本批量设置redis键值对
    服务器带宽上行与下行的区别
    性能测试之Jmeter插件安装
    sqlserver 启用邮箱服务
    sqlserver 自定义字符串分割函数.
    C# 重写思想
    CSS控制鼠标滑过时的效果
    js实现图片自动切换效果。
    SQL Server Management Studio 使用作业实现数据库备份
  • 原文地址:https://www.cnblogs.com/SasaL/p/10635180.html
Copyright © 2011-2022 走看看