在JSTL中使用Java中的Google数据存储(Spring MVC)foreach
我想将数据存储从java发送到jsp页面,并使用JSTL来获取这些数据 当我运行此代码时,它返回在JSTL中使用Java中的Google数据存储(Spring MVC)foreach,java,spring-mvc,google-app-engine,google-cloud-datastore,Java,Spring Mvc,Google App Engine,Google Cloud Datastore,我想将数据存储从java发送到jsp页面,并使用JSTL来获取这些数据 当我运行此代码时,它返回 HTTP ERROR 500 Problem accessing /. Reason: Could not find property email in class com.google.appengine.api.datastore.Entity 这是我的密码 HomeController.java Key customerKey = KeyFactory.createKey("Cu
HTTP ERROR 500
Problem accessing /. Reason:
Could not find property email in class com.google.appengine.api.datastore.Entity
这是我的密码
HomeController.java
Key customerKey = KeyFactory.createKey("Customer", "your name");
Entity customer = new Entity("Customer", customerKey);
customer.setProperty("name", "Test");
customer.setProperty("email", "test@gmail.com");
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
datastore.put(customer); //save it
Query query = new Query("Customer").addSort("name", Query.SortDirection.DESCENDING);
List<Entity> customers = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(10));
model.addAttribute("customerList", customers);
return "home";
home.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="java.util.List" %>
<%@ page import="com.google.appengine.api.datastore.Entity" %>
<%@ page session="false" %>
<table>
<c:forEach items="${customerList}" var="user">
<tr>
<td> <c:out value="${user.email}"/> </td>
</tr>
</c:forEach>
</table>
感谢您的每一个回答而不是使用属性设置值创建POJO类并初始化其中的名称和电子邮件属性,并为其生成getter和setter。并使用model属性传递POJO。现在,您可以在JSTlYes中使用POJO,使用POJO,您想尝试针对GAE-like Twist的对象映射框架: