初识EL
EL作用:简化JSP页面书写
EL格式:以”${“开始,以”}”结束
具体格式:
具体格式:
${表达式}
代码举例
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2021/4/6 Time: 14:45 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% pageContext.setAttribute("book1","JavaWeb"); pageContext.getRequest().setAttribute("book1","活着"); pageContext.getSession().setAttribute("book1","盗墓笔记"); pageContext.getServletContext().setAttribute("book1","我们仨"); %> ${pageScope.book1}<br> <hr /> ${requestScope.book1}<br> <hr /> ${sessionScope.book1}<br> <hr /> ${applicationScope.book1}<br> </body> </html>
使用EL获取不同域中的值
注意:如果不指明范围,全域查找,从小到大,找到即返回${book1}
NOTE:下一页项目示例