软件编程
位置:首页>> 软件编程>> java编程>> 使用Postman传递arraylist数据给springboot方式

使用Postman传递arraylist数据给springboot方式

作者:宁在春  发布时间:2022-08-27 01:13:01 

标签:Postman,arraylist,springboot

使用Postman传递arraylist数据给springboot

起因:需要做一个批量删除的功能,后台接收一个ArrayList ids

但是菜鸡小王不晓得postman 怎么传递集合数据给后端进行测试。

这个时候就只好发灰出csdn和百度的强大之处。

首先确定你的请求方式是什么

填写你的url路径

使用Postman传递arraylist数据给springboot方式

在这边补充一句 对象也是这样传递 以一个json 格式传递给后端。

后端接收的方法


   /*
    * 根据id 批量删除
    * @Param [ids]
    * @return com.crush.reponse.CommonsResponse
    **/
   @UseToken
   @DeleteMapping("/")
   @PreAuthorize("hasAuthority('ADMIN')")
   public CommonsResponse newsByType(@RequestBody ArrayList<Integer> ids){
       return new CommonsResponse(newsService.deleteNewsById(ids));
   }

这里的@RequestBody用于读取Http请求的body部分数据——就是我们的请求数据。

比如json或者xml。然后把数据绑定到 controller中方法的参数上,这里就是String json这个入参啦~

Postman传递arraylist参数给springboot的controller

使用Postman传递arraylist数据给springboot方式

来源:https://blog.csdn.net/weixin_45821811/article/details/115978483

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com