j2ee传递参数为空的问题
求帮忙 为什么传递的pnum是空的 导致
空指针异常?!
jsp代码:<a onclick="if(confirm('确定删除')) return true; else return false;" href="ProductDelete?ddh=<%=ddb.getPnum()%>" class="xhx"><font color="#0033CC">
删除</font></a></td>
servlet代码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
// TODO Auto-generated method stub
//super.doGet(request, response);
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//super.doPost(request, response);
request.setCharacterEncoding("gbk");
ProductService co = new ProductService();
String pnum="";
if(!request.getParameter("pnum").equals("")){
pnum = (String)request.getParameter("pnum");
pnum= new String(pnum.getBytes("ISO-8859-1"),"gbk");
System.out.println(pnum);
co.deleteProduct(pnum);
response.sendRedirect("ProductViewZZJ");
}
}
------解决方案--------------------难道不应该是request.getParameter("ddh")?
------解决方案--------------------你提交的是什么,拿的才是什么,名字改下。
href="ProductDelete?
ddh=<%=ddb.getPnum()%>"
request.getParameter("
pnum")