获取不到数据库的值

发布时间:2019-07-29 18:15:38


<table>

      <tr>

             <td>商品编号</td>

             <td>商品名称</td>

             <td style="text-align: center;">操作</td>

      </tr>

 <c:forEach items="${list}" var="product">

      <tr>

   <td>${product.id}</td><td>${product.name}</td>

<td>

             <a href="${pageContext.request.contextPath }/delete?id=${product.id}">删除</a>

             <a>|</a>

             <a href="${pageContext.request.contextPath }/toupdate?id=${product.id}">更新</a>

             </td>

      </tr>

</c:forEach>

      </table>


public class ProductAction {

private ProductService productService=new ProductServiceImpl();

HttpServletRequest request=ServletActionContext.getRequest();

HttpServletResponse response=ServletActionContext.getResponse();

public Product product=new Product();

public String findList(){

List<Product> list=productService.findList();

request.setAttribute("list", list);

return "list";

}

public String delete(){

int id=Integer.parseInt(request.getParameter("id"));

productService.deleteProduct(id);

return "del";

}

public String add(){

int id=Integer.parseInt(request.getParameter("id"));

String name=request.getParameter("name");

Product product=new Product(id,name);

productService.addProduct(product);

return "add";

}

public String toupdate(){

int id=Integer.parseInt(request.getParameter("id"));

Product product=productService.findById(id);

request.setAttribute("product", product);

return "toupdate";

}

public String update(){

int id=Integer.parseInt(request.getParameter("id"));

String name=request.getParameter("name");

Product product=new Product(id,name);

productService.updateProduct(product);

return "update";

}

}

为什么获取不到数据库的值

推荐回答

还没有选出推荐答案,请稍候访问或查看其他回答!
以上问题属网友观点,不代表本站立场,仅供参考!