首页 > 解决方案 > java.lang.NumberFormatException:检索查询字符串时为空

问题描述

我开发ecomerce网站,用户可以在主页上显示所有产品时获得类别明智的产品然后单击图像然后查询字符串传递并显示详细信息但是当在相同的描述中想要按类别过滤数据时出现以下错误java.lang .NumberFormatException:空

Product Bean
     public String singledispp(int pid)
        {

          ProductTbl p=ad.searchproduct(pid);
            product_id=p.getProductId();
            return "/client/single.xhtml?faces-redirect=true&product_id="+product_id;

        }

              public String dispbycat(int cid)
        {
            CategoryTbl ct=(CategoryTbl)ad.searchcat(cid);
         category_id=ct.getCategoryId();
         return "/client/products.xhtml?faces-redirect=true&categoryId="+category_id;
        }
            public Collection<ProductTbl> getproductbyid()
        {
       Map<String,String> params =FacesContext.getCurrentInstance().
                       getExternalContext().getRequestParameterMap();
            String parameterOne = params.get("product_id");
            int foo = Integer.parseInt(parameterOne);

            return ad.getAllProductByProductid(foo);
        }

        public Collection<ProductTbl>getbycat()
        {

           Map<String,String> params =FacesContext.getCurrentInstance().
                       getExternalContext().getRequestParameterMap();
             String parameterOne = params.get("categoryId");

             int foo = Integer.valueOf(parameterOne);
             dispbycat(foo);
             return  ad.getbycategoryid(foo);
        }

标签: java

解决方案


推荐阅读