解决错误:Optional int parameter ‘pageSize‘ is present but cannot be translated into a null value due to

23 篇文章 0 订阅

今天在学习springboot的时候,遇到了上面的问题,最开始一致找不到错误,然后查询资料,给的方法是:

将你的spring mvc中的int 修改为Integer就可以了,因为int不能装载null值。大家可以试一试

然后改完之后,我发现我的又出现了新的空指针异常的错误,然后就回去看我的spring mvc中编写的代码,发现是我的数据注入没有注入进去!

每个都要注入,大家别忘了!

又是学渣学习的一天。。。

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
报错信息"Required int parameter 'pageNo' is not present"意味着在请求中缺少必需的整型参数'pageNo'。这个问题通常是由于请求方式不正确引起的。一种解决方案是将请求方式改为GetMapping,这可能会解决问题。另一种解决方案是在发送post请求时,使用$.param()函数将需要发送的数据封装为一个对象,并将其作为参数传递给请求。例如,在mounted()方法中,可以这样使用$.param()函数将pagepageSize封装为一个对象: ```js mounted() { var obj = { page: this.page, pageSize: this.pageSize, }; this.$axios.post("/customer/query", $.param(obj)).then((res) => { console.log(res); console.log(res.data.data); }); }, ``` 另外,如果在浏览器中遇到这个错误,可能是由于必填的传输数据不正确造成的。可以考虑引入jQuery或使用Node环境中自带的qs库来进行数据转换和封装。这样可以确保传输的参数正确无误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Required Integer parameterpageNum‘ is not present](https://blog.csdn.net/yangli_/article/details/127887463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [解决“Required Integer parameter ‘xxx‘ is not present”问题](https://blog.csdn.net/NI_computer/article/details/109098255)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值