当我在页面上点击添加按扭时提交到action这个方法,就报这个错:public ActionForward  addTabuInfo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)throws Exception{
int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno"));
int secondDrugno = Integer.parseInt(request.getParameter("secondDrugno"));
//根据id查出相关信息

String hql = "from InjectionTabu i where i.firstDrug.id ="+firstDrugno+" and i.secondDrug.id = "+secondDrugno+"";
List list = drugInjectionTabuBiz.findByHql(hql);
if(list.size() != 0){
response.getWriter().print("no");
}else{
response.getWriter().print("ok");

}
return searchDrugInjection(mapping,form,request,response);
}它就报红字的地方错了!帮帮忙!谢谢!

解决方案 »

  1.   

    java.lang.NumberFormatException: For input string: "" 
    这次是错误的转型。
    比如: Integer.parseInt("abc");就报这样的错。
    你应该传一个数,要不就判断下。 
      

  2.   

    你输入的空的字符串""不能转换成int
    int firstDrugno=0;
    try{
     firstDrugno= Integer.parseInt(request.getParameter("firstDrugno"));
    }catch(Exception e){
     firstDrugno=给个默认值
    }
      

  3.   

    就是空字符串不能转换。
    你输出一下request.getParameter("firstDrugno")
    看看他得值
      

  4.   

    把request.getParameter("firstDrugno")输出来看看就知道了
      

  5.   

    int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno")); 
    转换之前判断一下
    String str = request.getParameter("firstDrugno");
    int firstDrugno = 0;
    if(str != null && !"".equals(str)) {
        firstDrugno = Integer.parseInt(str);
    }
      

  6.   

    int firstDrugno = Integer.parseInt("".equals(request.getParameter("firstDrugno"))?"0":request.getParameter("firstDrugno")); 
      

  7.   

    public ActionForward addTabuInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Eception

        try
        {
            int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno")); 
            int secondDrugno = Integer.parseInt(request.getParameter("secondDrugno")); 
            //根据id查出相关信息          String hql = "from InjectionTabu i where i.firstDrug.id ="+firstDrugno+" and i.secondDrug.id = "+secondDrugno+""; 
            List list = drugInjectionTabuBiz.findByHql(hql); 
            if(list.size() != 0)
            { 
               response.getWriter().print("no"); 
            }
            else
            { 
               response.getWriter().print("ok"); 
            } 
        }
        catch (NumberFormatException e) 
        {
            firstDrugno = xxxxxxxxxxx;
        }
        return searchDrugInjection(mapping,form,request,response);