package com.itheima.product.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.itheima.product.domain.Product;
import com.itheima.product.sercice.ProductService;
/**
* 查询所有商品的Servlet
*/
public class ProductFindAllServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/**
* 调用业务层: 页面跳转:
*/
try {
// 调用业务层:
ProductService productService = new ProductService();
List<Product> list = productService.findAll();
// 页面跳转:
request.setAttribute("list", list);
request.getRequestDispatcher("/jsp/product_list.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Insert title here</title>
</head>
<body>
<h1>商品的列表页面</h1>
<table border="1" width="800">
<tr>
<td>序号</td>
<td>商品名称</td>
<td>市场价格</td>
<td>商城价格</td>
<td>是否热门</td>
<td>是否下架</td>
<td>操作</td>
</tr>
<c:forEach var="p" items="${ list }">
<tr>
<td>序号</td>
<td>${p.name }</td>
<td>${p.market_price }</td>
<td>${p.shop_price }</td>
<td><c:if test="${p.is_hot == 1 }">
是
</c:if> <c:if test="${p.is_hot == 0 }">
否
</c:if></td>
<td><c:if test="${p.is_hot == 1 }">
已下架
</c:if> <c:if test="${p.is_hot == 0 }">
未下架
</c:if></td>
<td><a href="">修改</a>|<a href="">删除</a></td>
</tr>
</c:forEach>
</table>
</body>
</html>
大家看看哪些错了吗一直连接不上数据库的内容急死人了 哎!!
十月 04, 2017 12:35:35 下午
java.lang.ClassNotFoundException: com.itheima.product.servlet.ProductFindAllServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1143)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
相关分类