Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JSTL中使用Java中的Google数据存储(Spring MVC)foreach_Java_Spring Mvc_Google App Engine_Google Cloud Datastore - Fatal编程技术网

在JSTL中使用Java中的Google数据存储(Spring MVC)foreach

在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

我想将数据存储从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("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的对象映射框架: