原理分析
具体实现
下面是商品详情页面product_info.jsp显示的样子,我们最初的模板的静态资源已经写死了, 这里我们需要先对这个页面进行改造,使得到时候主页点击商品能输出对应的商品详情页面,具体改造方式在文章后面部分介绍。
修改index.jsp获取商品链接
在ProductServlet中增加findProductByPid方法
主要实现以下步骤:
获取商品pid
根据商品pid查询商品信息
将获取到的商品放入request
转发到/jsp/product_info.jsp
具体操作
在ProductService中添加
Product findProductByPid(String pid)throws Exception;
在ProductServiceImp中添加
@Override
public Product findProductByPid(String pid) throws Exception {
return ProductDao.