JSP中EL表达式的使用
首先需要导入依赖包
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
如果要在jsp中使用 Expression Language 即EL表达式,一定要设置 isELIgnored="false"
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<table class="tab" >
<tr >
<th>user_id</th>
<th>locale</th>
<th>birthyear</th>
<th>gender</th>
<th>joinedAt</th>
<th>location</th>
<th>timezone</th>
</tr>
<c:forEach items="${info}" var="users" >
<tr align="center">
<td>${users.user_id}</td>
<td>${users.locale}</td>
<td>${users.birthyear}</td>
<td>${users.gender}</td>
<td>${users.joinedAt}</td>
<td>${users.location}</td>
<td>${users.timezone}</td>
</tr>
</c:forEach>
</table>
</body>
</html>
当没有设置isELIgored=“false”,会出现如下结果:
正确的结果:

本文介绍了在JSP中如何使用EL表达式,强调了设置isELIgnored属性为"false"的重要性,解析了不设置该属性可能导致的问题,并展示了正确使用EL表达式后的预期结果。
8474

被折叠的 条评论
为什么被折叠?



