1
试图在没有任何JQuery详细信息的情况下使其工作。我真的很难找到一个易理解的例子,我将如何创建一个未编号的列表出来的一些JSON,我传递到一个字符串对象的前面。将JSON数据呈现给播放框架模板
我正在使用Play!框架。我的应用程序有一个方法,返回一个字符串持有一个json数组的项目。
GET /items controllers.Application.items()
的方法是这样的:
public static Result items() {
return ok(Json.toJson(Item.all()));
}
你会如何处理这些数据,才能有你的模板将其显示为无编号列表?
的数据,例如:
@Entity
public class Item {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int id;
public String title;
public String type;
public int quantity;
public BigDecimal unitPrice;
public Item() {}
public static List<Item> all() {
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("defaultPersistenceUnit");
EntityManager entityManager = entityManagerFactory.createEntityManager();
TypedQuery<Item> query = entityManager.createQuery("SELECT i FROM Item i", Item.class);
return query.getResultList();
}