我创建了以下 JSP 页面以显示数据库中的项目列表,但是当我在容器 tomcat7 中运行应用程序时,我得到一个空白页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lista de produtos</title>
</head>
<body>
<div id="display">
<table border=2>
<thead>
<tr>
<th>Model</th>
<th>Vendor</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<c:forEach var="item" items="${list}">
<tr>
<td><c:out value="${item.model}"/></td>
<td><c:out value="${item.vendor}"/></td>
<td><c:out value="${item.price}"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
此页面由我的 servlet 中的以下方法 doGet 触发:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String parametro = request.getParameter("p");
List<equipment> lista = new ArrayList<equipment>();
if(parametro.equals("*")) {
try {
lista = FindAllItens();
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
try {
lista = FindItens(parametro);
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
request.getSession().setAttribute("list", lista);
request.getRequestDispatcher("display.jsp").forward(request, response);
}
有人知道使页面正常工作可能缺少什么?