积木报表版本:`version 1.2.1` 后台环境: `Spring Boot 2.3.5.RELEASE` ### **情况一:API数据集在请求地址上拼接条件** ![](https://img.kancloud.cn/5c/d9/5cd98fcf33e2ffc6312730b3726f05d7_1889x497.png) 使用的时候可以设置参数默认值,还可以**在预览地址后直接拼接条件覆盖默认值**如:`http://localhost:8080/jeecg-boot/jmreport/view/12345678901?name=scott` - GET请求,使用RequestParam接收 ~~~ @GetMapping("/getReq") public JSONObject getReq(@RequestParam(name="name",required = false) String name){ } ~~~ - POST请求,也需要RequestParam接收,***post不推荐此种方式传参*** ~~~ @PostMapping("/postReq") public JSONObject postReq(@RequestParam(name="name",required = false) String name){ } ~~~ ------ ### **情况二:API数据集配置查询条件,如下例将name设置查询** ![](https://img.kancloud.cn/80/e1/80e1175e1414c1fff259f7bb0ad93251_1860x330.png) 使用的时候需要用户自己在预览页面录入查询条件: ![](https://img.kancloud.cn/81/6e/816eeb812184016d55bb844487bb30eb_1044x324.png) - 如果是GET请求,使用RequestParam接收 ~~~ @GetMapping("/getReq") public JSONObject getReq(@RequestParam(name="name",required = false) String name){ } ~~~ ----- - 如果是POST请求,使用`RequestBody json`接收 ~~~ @PostMapping("/postReq") public JSONObject postReq(@RequestBody JSONObject json){ String name = json.getString("name"); } ~~~ 或者实体,两种方式都必须加注解`@RequestBody` ~~~ @PostMapping("/postReq") public JSONObject postReq(@RequestBody TestUser user){ String name = user.getName(); } ~~~