【发布时间】:2021-04-27 05:51:58
【问题描述】:
我有一个简单的 servlet,我在其中设置一个属性,当我尝试在 JSP 中获得相同的属性时,我得到的是静态内容,而不是 JSP 页面中的动态数据。
小服务程序
....
request.setAttribute("auditLog",auditLogs.get(1));
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request, response);
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<h2>Enter user's email here</h2>
<form action="getUserData">
<input type="email" name="email"/>
<input type = "submit" value="Submit"/>
</form>
<br>
The audit logs here
${auditLog}
${auditLog.getAuditLogId()}
<c:out value="${auditLog}"/>
</body>
</html>
输出
【问题讨论】: