问题描述
我正在 InteliJ 上使用 JDBC 和 Servlet 构建网站,但是当我运行时,尽管我添加了所有依赖项,但仍无法正确读取标签。这是我的 productView.jsp
文件:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<Meta charset="UTF-8">
<title>Product List</title>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<jsp:include page="menu.jsp"></jsp:include>
<h3>Product List</h3>
<table border="1" cellpadding="5" cellspacing="1">
<tr>
<th>Product Id</th>
<th>Name</th>
<th>Price</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<c:forEach items="${productList}" var="product">
<tr>
<td>${product.productId}</td>
<td>${product.name}</td>
<td>${product.price}</td>
<td><a href="editProduct?id=${product.id}">Edit</a></td>
<td><a href="deleteProduct?id=${product.id}">Delete</a></td>
</tr>
</c:forEach>
</table>
<a href="createProduct">Create Product</a>
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>
这是我的 servlet:
@WebServlet(urlPatterns = { "/productList" })
public class ProductList extends HttpServlet {
private static final long serialVersionUID = 1L;
public ProductList() {
super();
}
@Override
protected void doGet(HttpServletRequest request,HttpServletResponse response)
throws servletexception,IOException {
Connection conn = Utils.getStoredConnection(request);
List<Product> list = null;
try {
list = dbutils.queryProduct(conn);
} catch (sqlException e) {
e.printstacktrace();
}
request.setAttribute("productList",list);
System.out.println(list);
Requestdispatcher dispatcher = request.getServletContext()
.getRequestdispatcher("/WEB-INF/view/productListView.jsp");
dispatcher.forward(request,response);
}
@Override
protected void doPost(HttpServletRequest request,IOException {
doGet(request,response);
}
}
在我的数据库中有两种产品。
我已经在 pom.xml
文件中添加了所有 JSTL 库,但是当我运行服务器时,结果是这样的:
我该如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)