6.1EL表达式:${}
pom.xml依赖:
<!--Jstl表达式依赖-->
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl-api -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
<!--standard标签库-->
<!-- https://mvnrepository.com/artifact/taglibs/standard -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
功能:
- 获取数据。
- 执行运算。
- 获取Web开发的常用对象。
Jsp标签:
<%--jsp:include 之前列举过了--%>
<%--生成的网页会为:http://localhost:8080/jsptag.jsp?name=Edwin_Duan&age=17 --%>
<%--jsp:forward,跳槽页面--%>
<jsp:forward page="/jsptag2.jsp">
<%--jsp:param,设置变量和值。--%>
<jsp:param name="name" value="Edwin_Duan"/>
<jsp:param name="age" value="17"/>
</jsp:forward>
代码测试:
Jsptag.jsp:
<%--
Created by IntelliJ IDEA.
User: 元
Date: 2020.6.9
Time: 上午 11:09
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Tag</title>
</head>
<body>
<h1>Tag1</h1>
<%--jsp:include 之前列举过了--%>
<%--生成的网页会为:http://localhost:8080/jsptag.jsp?name=Edwin_Duan&age=17 --%>
<%--jsp:forward,跳槽页面--%>
<jsp:forward page="/jsptag2.jsp">
<%--jsp:param,设置变量和值。--%>
<jsp:param name="name" value="Edwin_Duan"/>
<jsp:param name="age" value="17"/>
</jsp:forward>
</body>
</html>
Jsptag2.jsp:
<%--
Created by IntelliJ IDEA.
User: 元
Date: 2020.6.9
Time: 上午 11:10
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Tag2</title>
</head>
<body>
<h1>Tag2</h1>
<%--取出参数--%>
Name:<%= request.getParameter("name")%>
Age:<%= request.getParameter("age")%>
</body>
</html>
申请访问jsptag.jsp:
《成功的花》——冰心
成功的花,
人们只惊羡她现时的明艳!
然而当初她的芽儿,
浸透了奋斗的泪泉,
洒遍了牺牲的血雨!
参考文献
《【狂神说Java】JavaWeb入门到实战》
2020.06.09