错误的意思是: "可选的int参数'fundID'存在但由于被声明为基本类型而无法转换为空值"

意思是fundID被申明为int的基本数据类型, 不能转换为字符串的null值. 难道是在参数调用

的时候, 需要把fundID设置为对象类型吗? 答案是正确的. 

    @RequestMapping(value = "/fund-purchase")
    public String fundPurchase(int fundID) {
        Fund fund = fundService.selectFundByID(1);
        System.out.println("fund: " + fund);
        return null;
    }

解决办法: int 改为 Integer,

                前端通过url传递过来的数据, 改为对象类型

    @RequestMapping(value = "/fund-purchase")
    public String fundPurchase(Integer fundID) {
        Fund fund = fundService.selectFundByID(1);
        System.out.println("fund: " + fund);
        return null;
    }

问题解决!

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2021-07-25
  • 2021-07-06
  • 2021-04-18
  • 2022-12-23
  • 2021-12-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
相关资源
相似解决方案