EL表达式
EL表达式(express language):${}
- 获取数据
- 执行运算
- 获取web开发的常用对象
获取当前页面的数据
原来的jsp代码
<% for (int i = 0; i < 5; i++) { %>
<p>HelloWorld <%=i%> </p>
<% } %>
EL表达式写法
<% for (int i = 0; i < 5; i++) { %>
<p>HelloWorld ${i} </p>
<% } %>
获取表单传递的数据
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form action="JSTL.jsp" method="post">
<!--格式为${param.参数name}-->
username:${param.username}<br>
<input type="text" name="username">
<input type="submit" value="提交">
</form>
</body>
</html>