解决办法(有点low哈哈哈)

    String id = String.format("%s", request.getParameter("productId"));
    int realId = Integer.parseInt(id.replaceAll(" ", ""));
    /*
    这里用realId获取商品的id。

    直接用request.getParameter("productId")获取从上一个JSP页面传过来的id的话,
    会报一个   java.lang.NumberFormatException: For input string: " 2"  的错误,
    错误原因不明,这里用String类的replaceAll()将传过来的参数中的空格去掉了
     */

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
猜你喜欢
  • 2021-07-20
  • 2021-12-15
  • 2021-11-16
  • 2021-09-27
  • 2021-08-23
  • 2022-01-23
相关资源
相似解决方案