EASONLEELEE 2015-04-14 02:54 采纳率: 22.2%
浏览 8291
已采纳

jsp中提交到Servlet的表单获取的值为什么都为NULL?

------------------addProduct.jsp---------------
<form action="${pageContext.request.contextPath}/servlet/ManagerServlet?operation=addProduct" method="post"">

 <table width="80%" border="0">
商品全称:<input type="text" id="Pro_name" name="Pro_name" style="height:30px" >
商品编码:<input type="text" style="height:30px" id="Pro_code" name="Pro_code">
                 <input type="submit" value="保存"/>

</form>

--------------------------ManagerServlet-------------------
public class ManagerServlet extends HttpServlet {
private BusinessService s = new BusinessServiceImpl();

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String operation = request.getParameter("operation");
    if("addProduct".equals(operation)){
        addProduct(request, response);
    }
}
//添加产品到数据库中
private void addProduct(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    Product p = WebUtil.fillBean(request, Product.class);
    s.addProduct(p);
    System.out.println(p.getPro_name()+p.getPro_id());
}


public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doGet(request, response);
}

}


  • 写回答

10条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号
      • ¥15 利用kmeans或kshape聚类分析对归一化的无量纲时间-降雨序列进行聚类
      • ¥20 misc尽快完成,急! ! !
      • ¥15 protel99.SE提示一下弹窗
      • ¥15 银河麒麟v10 执行.run失败如何解决
      • ¥15 如何用Python打开LA文件