Jan*_*kes 3 java google-app-engine jsp jsp-tags
我需要在JSP数据存储区查询结果中显示.我获取数据并将它们转发到JSP文件中:
Query query = new Query("oAuth", key);
List<Entity> users = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(5));
try {
// Set the attribute and Forward to hello.jsp
req.setAttribute ("users", users); // to save your temporary calculations.
req.getRequestDispatcher("/sharemarkerusers.jsp").forward(req, resp);
} catch (Exception ex) {
ex.printStackTrace ();
}
Run Code Online (Sandbox Code Playgroud)
这是我的jsp文件的内容
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<html>
<body>
<table>
<c:forEach items="${users}" var="user">
<tr>
<td>${user.userEmail}</td>
</tr>
</c:forEach>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是我得到了结果:在com.google.appengine.api.datastore.Entity类中找不到属性userEmail
好吧,当我在单元格中显示只是用户变量时,它实际显示:
<html>
<body>
<table>
<tr>
<td><Entity [oAuth("******")/oAuth("*********")]:
accessToken = ***********
accessTokenSecret = ************
userEmail = usersemail@example.com
>
</td>
</tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所以问题是,我可以通过$ {user.?}标签访问实体的属性吗?forEach循环应该.
非常感谢你.