不从数据库应用引擎返回数据

时间:2014-05-23 04:15:26

标签: java google-app-engine

我的Java Google App Engine项目没有从数据库返回数据,也没有显示错误。

关注JSP页面:

<html>
<head>
<title>Pessoas</title>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
</head>

<body>
<%
PessoaDao dao = PessoaDao.INSTANCE;
List<Pessoa> pessoas;
pessoas = dao.listPessoas();
%>

Numero total de pessoas: <% pessoas.size(); %> Pessoas.

<table>
<tr>
<th>Nome</th>
<th>Idade</th>
</tr>
<%for (Pessoa p : pessoas) {%>
<tr>
<td>
<%p.getNome(); %>
</td>
<td>
<%p.getIdade();  %>
</td>
</tr>
<% } %>
</table>

按照我的课程返回数据:

public List<Pessoa> listPessoas()
    {
        EntityManager em = EMFService.get().createEntityManager();

        Query q = em.createQuery("select p from Pessoa p");

        List<Pessoa> pessoas = null;
        pessoas = new ArrayList<Pessoa>(q.getResultList());
        return pessoas;
    }

还有其他方法可以从数据库中返回数据吗?

0 个答案:

没有答案
相关问题