内容
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> *{ color: black; font-size: 45px; } </style> <title>Insert title here</title> </head> <body> <!-- 算数运算 --> ${4+6 } ${4/6 } ${4*6 } <br> ${3222*89 } <br> ${23 mod 5 }<br> ${23/5 }<br> <% request.setAttribute("age", 56); %> ${age-5 }<br> <br> <!-- 关系运算符 --> ${age/11>7 }<br> ${age/11<=7 }<br> ${age/11>=7 }<br> ${age/11<7 }<br> ${age/11==7 }<br> <!-- 逻辑运算符 --> ${ age mod 3==0 && age/5 ge 2}<br> ${ age mod 3 ==0|| age/5 ge 2}<br> <%-- 空运算符--%> <% int [] nums =null; pageContext.setAttribute("n", nums); %> ${empty(n) }<br> <!-- 三元运算符 --> ${age/2+3-6>45?"AAA":"BBB" }<br> <!--练习题 --> <h2> ${23+67*90 }<br> ${3>2?3:2 }<br> </h2> </body> </html>
第一个EL表达式${}
数组的方式 获取
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> *{ font-size: 30px; } h1{ color: red; } h6{ color: red; background-color: black; } </style> <title>数组集合</title> </head> <body> <h1>数组的方式</h1> <% String [] grirs={"@AAAA","@BBBB","@CCCC","@DDDD"}; session.setAttribute("gs", grirs); %> <!-- 方式一java代码 --> <% String [] gs=(String[])session.getAttribute("gs"); %> <%=gs[0] %><br><%=gs[1] %><br><%=gs[2] %><br><%=gs[3] %><br> <!-- EL表达式 --> <h6>String [] gs=(String[])session.getAttribute("gs");</h6> <hr> ${gs[0]},${gs[1]},${gs[2]},${gs[3]} </body> </html>
集合的方式获取
<%@page import="java.util.HashMap"%> <%@page import="java.util.Map"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@page import="comabc.Dog"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> *{ font-size: 30px; } h1{ color: red; } h6{ color: red; background-color: black; } </style> <title>数组集合</title> </head> <body> <h1>数组的方式</h1> <% String [] grirs={"@AAAA","@BBBB","@CCCC","@DDDD"}; session.setAttribute("gs", grirs); %> <!-- 方式一java代码 --> <% String [] gs=(String[])session.getAttribute("gs"); %> <%=gs[0] %><br><%=gs[1] %><br><%=gs[2] %><br><%=gs[3] %><br> <!-- EL表达式 --> <h6>String [] gs=(String[])session.getAttribute("gs");</h6> <hr> ${gs[0]},${gs[1]},${gs[2]},${gs[3]} <h1>集合的方式</h1> <h6>session.setAttribute("l", list);</h6> <% List <Integer> list=new ArrayList<>(); list.add(89); list.add(79); list.add(69); list.add(59); session.setAttribute("l", list); %> <!-- El表达式的获取 --> ${l[0]},${l[1]},${l[2]},${l[3]}<br> <h1>MAP集合的方式</h1> <h6>request.setAttribute("bo", map);</h6> <% Map<String,String>map =new HashMap<>(); map.put("book1","JAVA程序设计"); map.put("book2","JAVA程序设计1"); map.put("book3","JAVA程序设计2"); map.put("book4","JAVA程序设计3"); map.put("book5","JAVA程序设计4"); request.setAttribute("bo", map); %> <!-- MAP集合查找 El--> ${bo.book1}<br> ${bo.book2}<br> ${bo.book3}<br> ${bo.book4}<br> ${bo.book5}<br> <%-- <h1>实体类</h1> <h6>application.setAttribute("os", odogs);</h6> <% List <Dog> odogs =new ArrayList<>(); odogs.add(new Dog("AA",1,"pink")); odogs.add(new Dog("BB",2,"blsck")); odogs.add(new Dog("CC",3,"blsck")); application.setAttribute("os", odogs); %> ${os[1].name,$os[2].color} --%> </body> </html>
实体类的获取思考?下次解密。
这是一个案例
<%@page import="java.util.HashMap"%> <%@page import="java.util.Map"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size: 34px; } </style> </head> <body> <% Map<String,String>map =new HashMap<>(); map.put("book1","JAVA程序设计"); map.put("book2","JAVA程序设计1"); map.put("book3","JAVA程序设计2"); map.put("book4","JAVA程序设计3"); map.put("book5","JAVA程序设计4"); request.setAttribute("bo", map); Map<String,String>map1 =new HashMap<>(); map1.put("boy1","AAAA"); map1.put("boy2","BB"); map1.put("boy3","CC"); map1.put("boy4","DD"); request.setAttribute("boy", map1); List<Map<String,String>>oList =new ArrayList<>(); oList.add(map); oList.add(map1); pageContext.setAttribute("ot", oList); %> <!-- MAP集合查找 --> ${bo.book1}<br> ${bo.book2}<br> ${bo.book3}<br> ${bo.book4}<br> ${bo.book5}<br> <h1 style="color: red;">===============</h1> ${boy.boy1}<br> ${boy.boy2}<br> ${boy.boy3}<br> ${boy.boy4}<br> <h1 style="color: green;">===============</h1> ${ot[0].book3} ,<br> <%-- ${0t[1]["boy2"] } --%> <!-- 集合中 --> ${ot[1].boy1}<br> ${ot[1].boy2}<br> ${ot[1].boy3}<br> </body> </html>
第二部分思考一下你定义了四种数据,你有几种方式可以获得呢?接下来看过程。
@1四大域
## seesion 浏览器不切
## application 服务器不关闭
## request:请求转发跳转页面的情况,只能两个页面共享数据
## pageContext:该对象中只能页面自己用
## 才能用setAttribute的方法
## 将四作用域排序**
## **pageContext request seesionn application
@2
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size:30px; font-weight: bold; background:pink; } h1{ background-color: green; color: black; font-weight: bold; } h2{ color: black; border: 2px solid; background-color: yellow; } h3{ color: pink; background-color: red; } </style> </head> <body> <h1> ## seesion 浏览器不切 ## application 服务器不关闭 ## request:请求转发跳转页面的情况,只能两个页面共享数据 ## pageContext:该对象中只能页面自己用 ## 才能用setAttribute的方法 ## 将四作用域排序** ## **pageContext request seesionn application** </h1> <!-- JSP 中的四大域 存放数据称为四大域 按照作用域从小到大 1 pageContext:页面本身使用,其他页面并不能共享数据。 2 resquest; 只能在请求转发的情况下共享数据 3 Session 在不切浏览器的情况下 4 application 在不关闭浏览器的前提下,任何都能共享数据。 --> <h1>===========这个是什么?=====${pageScope.a } ${sessionScope.a }<br> ${sessionScope.a }<br> ${applicationScope.a }<br></h1> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("b", "request@2.BROW 123"); session.setAttribute("c", "session@3.DFER true"); application.setAttribute("d", "application@4.PINK"); %> <!-- 方式一 获取--> <%=pageContext.getAttribute("a") %><br> <%=request.getAttribute("b") %><br> <%=session.getAttribute("c") %><br> <%=application.getAttribute("d") %><br> <br><br><hr> </body> </html>
@2方式二的获取
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size: 34px; } </style> </head> <body> <!-- JSP 中的四大域 存放数据称为四大域 按照作用域从小到大 1 pageContext:页面本身使用,其他页面并不能共享数据。 2 resquest; 只能在请求转发的情况下共享数据 3 Session 在不切浏览器的情况下 4 application 在不关闭浏览器的前提下,任何都能共享数据。 --> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("a", "request@2.BROW"); session.setAttribute("a", "session@3.DFER"); application.setAttribute("a", "application@4.PINK"); %> <!-- 方式一 获取--> <%=pageContext.getAttribute("a") %><br> <%=request.getAttribute("a") %><br> <%=session.getAttribute("a") %><br> <%=application.getAttribute("a") %><br> <br><br><hr> <!-- 方式二 --> <%=pageContext.getAttribute("a") %> <%=pageContext.getAttribute("a",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.APPLICATION_SCOPE ) %><br> <br><br><hr>
@3方式三
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size:30px; font-weight: bold; background:pink; } h1{ background-color: green; color: black; font-weight: bold; } h2{ color: black; border: 2px solid; background-color: yellow; } h3{ color: pink; background-color: red; } </style> </head> <body> <h1> ## seesion 浏览器不切 ## application 服务器不关闭 ## request:请求转发跳转页面的情况,只能两个页面共享数据 ## pageContext:该对象中只能页面自己用 ## 才能用setAttribute的方法 ## 将四作用域排序** ## **pageContext request seesionn application** </h1> <!-- JSP 中的四大域 存放数据称为四大域 按照作用域从小到大 1 pageContext:页面本身使用,其他页面并不能共享数据。 2 resquest; 只能在请求转发的情况下共享数据 3 Session 在不切浏览器的情况下 4 application 在不关闭浏览器的前提下,任何都能共享数据。 --> <h1>===========这个是什么?=====${pageScope.a } ${sessionScope.a }<br> ${sessionScope.a }<br> ${applicationScope.a }<br></h1> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("b", "request@2.BROW 123"); session.setAttribute("c", "session@3.DFER true"); application.setAttribute("d", "application@4.PINK"); %> <!-- 方式一 获取--> <%=pageContext.getAttribute("a") %><br> <%=request.getAttribute("b") %><br> <%=session.getAttribute("c") %><br> <%=application.getAttribute("d") %><br> <br><br><hr> <%=pageContext.getAttribute("a") %><br> <%=pageContext.getAttribute("b",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("c",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("d",pageContext.APPLICATION_SCOPE ) %><br> <h1>====================代码实例0=========================</h1> <!-- 方式二 --> <%=pageContext.getAttribute("a") %><br> <%=pageContext.getAttribute("a",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.APPLICATION_SCOPE ) %><br> <br><br><hr> <!-- -方式三 快速查找 findAttribute 改方法查找数据作用域从小到大 pageContext resquest; Session application --> <h3>====================代码实例一=========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("b") %><br> <br><br><hr> <h3>==================代码实例二===========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("c") %><br> <%=pageContext.findAttribute("c") %><br> <br><br><hr> <h3>===================代码实例三==========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("c") %><br> <%=pageContext.findAttribute("d") %><br> <br><br><hr> <h2>==========================方案四======================</h2> <!-- 方式四 --> <!-- EL表达式语法 --> <!-- 该表达式其内部就是 findAttribute 快速查找 请看下面代码 可以获得八大数据类型--> <!-- findAttribute === ${a }<br> --> <h2>================代码实例0=============================</h2> ${a }<br> ${a }<br> ${a}<br> ${a}<br> <h2>================代码实例1============================</h2> ${a }<br> ${b }<br> ${b}<br> ${b}<br> <h2>================代码实例2============================</h2> ${a }<br> ${b }<br> ${c}<br> ${c}<br> <h2>================代码实例3============================</h2> ${a }<br> ${b }<br> ${c}<br> ${d}<br> <h3>-------------------------------解决问题内容--------------------------------</h3> </body> </html>
运行结果
观察上面的图你会看出几个问题。
针对上面问题引出EL表达式 请看方案四。
@4方案四
<!-- EL pageContextScope --> ${pageScope.a }<br> <!-- requestScope --> ${requestScope.a }<br> <!-- sessionScope --> ${sessionScope.a }<br> <!-- applicationScope --> ${applicationScope.a }<br>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>四大域</title> <style type="text/css"> *{ color: red; font-size: 45px; } </style> </head> <body> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("a", "request@2.BROW 123"); session.setAttribute("a", "session@3.DFER true"); application.setAttribute("a", "application@4.PINK"); %> <!-- EL pageContextScope --> ${pageScope.a }<br> <!-- requestScope --> ${requestScope.a }<br> <!-- sessionScope --> ${sessionScope.a }<br> <!-- applicationScope --> ${applicationScope.a }<br> </body> </html>
案例全面代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size:30px; font-weight: bold; background:pink; } h1{ background-color: green; color: black; font-weight: bold; } h2{ color: black; border: 2px solid; background-color: yellow; } h3{ color: pink; background-color: red; } </style> </head> <body> <h1> ## seesion 浏览器不切 ## application 服务器不关闭 ## request:请求转发跳转页面的情况,只能两个页面共享数据 ## pageContext:该对象中只能页面自己用 ## 才能用setAttribute的方法 ## 将四作用域排序** ## **pageContext request seesionn application** </h1> <!-- JSP 中的四大域 存放数据称为四大域 按照作用域从小到大 1 pageContext:页面本身使用,其他页面并不能共享数据。 2 resquest; 只能在请求转发的情况下共享数据 3 Session 在不切浏览器的情况下 4 application 在不关闭浏览器的前提下,任何都能共享数据。 --> <h1>===========这个是什么?=====${pageScope.a } ${sessionScope.a }<br> ${sessionScope.a }<br> ${applicationScope.a }<br></h1> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("b", "request@2.BROW 123"); session.setAttribute("c", "session@3.DFER true"); application.setAttribute("d", "application@4.PINK"); %> <!-- 方式一 获取--> <%=pageContext.getAttribute("a") %><br> <%=request.getAttribute("b") %><br> <%=session.getAttribute("c") %><br> <%=application.getAttribute("d") %><br> <br><br><hr> <%=pageContext.getAttribute("a") %><br> <%=pageContext.getAttribute("b",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("c",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("d",pageContext.APPLICATION_SCOPE ) %><br> <h1>====================代码实例0=========================</h1> <!-- 方式二 --> <%=pageContext.getAttribute("a") %><br> <%=pageContext.getAttribute("a",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.APPLICATION_SCOPE ) %><br> <br><br><hr> <!-- -方式三 快速查找 findAttribute 改方法查找数据作用域从小到大 pageContext resquest; Session application --> <h3>====================代码实例一=========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("b") %><br> <br><br><hr> <h3>==================代码实例二===========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("c") %><br> <%=pageContext.findAttribute("c") %><br> <br><br><hr> <h3>===================代码实例三==========================</h3> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("b") %><br> <%=pageContext.findAttribute("c") %><br> <%=pageContext.findAttribute("d") %><br> <br><br><hr> <h2>==========================方案四======================</h2> <!-- 方式四 --> <!-- EL表达式语法 --> <!-- 该表达式其内部就是 findAttribute 快速查找 请看下面代码 可以获得八大数据类型--> <!-- findAttribute === ${a }<br> --> <h2>================代码实例0=============================</h2> ${a }<br> ${a }<br> ${a}<br> ${a}<br> <h2>================代码实例1============================</h2> ${a }<br> ${b }<br> ${b}<br> ${b}<br> <h2>================代码实例2============================</h2> ${a }<br> ${b }<br> ${c}<br> ${c}<br> <h2>================代码实例3============================</h2> ${a }<br> ${b }<br> ${c}<br> ${d}<br> <h3>-------------------------------解决问题内容--------------------------------</h3> <!-- 解决上面的问题 --> <!-- EL pageContextScope --> ${pageScope.a }<br> <!-- requestScope --> ${sessionScope.a }<br> <!-- sessionScope --> ${sessionScope.a }<br> <!-- applicationScope --> ${applicationScope.a }<br> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size: 34px; } </style> </head> <body> <!-- JSP 中的四大域 存放数据称为四大域 按照作用域从小到大 1 pageContext:页面本身使用,其他页面并不能共享数据。 2 resquest; 只能在请求转发的情况下共享数据 3 Session 在不切浏览器的情况下 4 application 在不关闭浏览器的前提下,任何都能共享数据。 --> <% pageContext.setAttribute("a", "pageContext@1APPLE"); request.setAttribute("a", "request@2.BROW"); session.setAttribute("a", "session@3.DFER"); application.setAttribute("a", "application@4.PINK"); %> <!-- 方式一 获取--> <%=pageContext.getAttribute("a") %><br> <%=request.getAttribute("a") %><br> <%=session.getAttribute("a") %><br> <%=application.getAttribute("a") %><br> <br><br><hr> <!-- 方式二 --> <%=pageContext.getAttribute("a") %> <%=pageContext.getAttribute("a",pageContext.REQUEST_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.SESSION_SCOPE ) %><br> <%=pageContext.getAttribute("a",pageContext.APPLICATION_SCOPE ) %><br> <br><br><hr> <!-- -方式三 快速查找 findAttribute --> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("a") %><br> <%=pageContext.findAttribute("a") %><br> <br><br><hr> </body> </html>
<%@page import="java.util.HashMap"%> <%@page import="java.util.Map"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@page import="comabc.Dog"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> *{ font-size: 30px; } h1{ color: red; } h6{ color: red; background-color: black; } </style> <title>数组集合</title> </head> <body> <h1>数组的方式</h1> <% String [] grirs={"@AAAA","@BBBB","@CCCC","@DDDD"}; session.setAttribute("gs", grirs); %> <!-- 方式一java代码 --> <% String [] gs=(String[])session.getAttribute("gs"); %> <%=gs[0] %><br><%=gs[1] %><br><%=gs[2] %><br><%=gs[3] %><br> <!-- EL表达式 --> <h6>String [] gs=(String[])session.getAttribute("gs");</h6> <hr> ${gs[0]},${gs[1]},${gs[2]},${gs[3]} <h1>集合的方式</h1> <h6>session.setAttribute("l", list);</h6> <% List <Integer> list=new ArrayList<>(); list.add(89); list.add(79); list.add(69); list.add(59); session.setAttribute("l", list); %> <!-- El表达式的获取 --> ${l[0]},${l[1]},${l[2]},${l[3]}<br> <h1>MAP集合的方式</h1> <h6>request.setAttribute("bo", map);</h6> <% Map<String,String>map =new HashMap<>(); map.put("book1","JAVA程序设计"); map.put("book2","JAVA程序设计1"); map.put("book3","JAVA程序设计2"); map.put("book4","JAVA程序设计3"); map.put("book5","JAVA程序设计4"); request.setAttribute("bo", map); %> <!-- MAP集合查找 El--> ${bo.book1}<br> ${bo.book2}<br> ${bo.book3}<br> ${bo.book4}<br> ${bo.book5}<br> <%-- <h1>实体类</h1> <h6>application.setAttribute("os", odogs);</h6> <% List <Dog> odogs =new ArrayList<>(); odogs.add(new Dog("AA",1,"pink")); odogs.add(new Dog("BB",2,"blsck")); odogs.add(new Dog("CC",3,"blsck")); application.setAttribute("os", odogs); %> ${os[1].name,$os[2].color} --%> </body> </html>
<%@page import="java.util.HashMap"%> <%@page import="java.util.Map"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> *{ font-size: 34px; } </style> </head> <body> <% Map<String,String>map =new HashMap<>(); map.put("book1","JAVA程序设计"); map.put("book2","JAVA程序设计1"); map.put("book3","JAVA程序设计2"); map.put("book4","JAVA程序设计3"); map.put("book5","JAVA程序设计4"); request.setAttribute("bo", map); Map<String,String>map1 =new HashMap<>(); map1.put("boy1","AAAA"); map1.put("boy2","BB"); map1.put("boy3","CC"); map1.put("boy4","DD"); request.setAttribute("boy", map1); List<Map<String,String>>oList =new ArrayList<>(); oList.add(map); oList.add(map1); pageContext.setAttribute("ot", oList); %> <!-- MAP集合查找 --> ${bo.book1}<br> ${bo.book2}<br> ${bo.book3}<br> ${bo.book4}<br> ${bo.book5}<br> <h1 style="color: red;">===============</h1> ${boy.boy1}<br> ${boy.boy2}<br> ${boy.boy3}<br> ${boy.boy4}<br> <h1 style="color: green;">===============</h1> ${ot[0].book3} ,<br> <%-- ${0t[1]["boy2"] } --%> <!-- 集合中 --> ${ot[1].boy1}<br> ${ot[1].boy2}<br> ${ot[1].boy3}<br> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> *{ color: black; font-size: 45px; } </style> <title>Insert title here</title> </head> <body> <!-- 算数运算 --> ${4+6 } ${4/6 } ${4*6 } <br> ${3222*89 } <br> ${23 mod 5 }<br> ${23/5 }<br> <% request.setAttribute("age", 56); %> ${age-5 }<br> <br> <!-- 关系运算符 --> ${age/11>7 }<br> ${age/11<=7 }<br> ${age/11>=7 }<br> ${age/11<7 }<br> ${age/11==7 }<br> <!-- 逻辑运算符 --> ${ age mod 3==0 && age/5 ge 2}<br> ${ age mod 3 ==0|| age/5 ge 2}<br> <%-- 空运算符--%> <% int [] nums =null; pageContext.setAttribute("n", nums); %> ${empty(n) }<br> <!-- 三元运算符 --> ${age/2+3-6>45?"AAA":"BBB" }<br> <!--练习题 --> <h2> ${23+67*90 }<br> ${3>2?3:2 }<br> </h2> </body> </html>