java - 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);
}
解决方案
推荐阅读
- python - DRF:只有作者可以创建或更新图书权限
- javascript - Cookie 被设置到不同的域(Node.js、Angular)
- c - 为什么我在 C 中的电子邮件检查器不起作用?(我使用 ispunct 来检测电子邮件上是否有 @,但它似乎不起作用)
- python - 仅在第一个 epoch 验证损失为零
- magnolia - 如何在标准 magnolia 5.7 表单上预填充输入/隐藏字段
- r - 运行应用程序时出现闪亮错误:match.arg(position) 中的错误:'arg' 必须为 NULL 或字符向量
- r - 如何提高 Rstudio 中导出的 ggsurvplot 图像的分辨率
- sql - 取最后一个变化值
- javascript - Node.js 将 Buffer 转换为对象/函数
- oracle - 比较 oracle apex 中的时间戳时,调用“<=”时参数的数量或类型错误