Spring boot 接收数组

前端ajax传参发请求:

$.ajax({
                    url:'/tjcx/qyzxcx/cwzb/gjcwzb',
                    type:'post',
                    data:{
                        'djxh':djxh,
                        'nds':app.lastYears
                    },
                    success:function (res) {
                        let data = res.data;
                        if (data.code === 200) {
                            app.tableData6 = data.data;
                        }
                    }
                })

发出的数组叫nds

接收:

    @ApiOperation("查询财务报表数据")
    @PostMapping("/gjcwzb")
    public ApiResponse getDataByDjxh(@RequestParam("djxh") @ApiParam(name = "djxh", value = "登记序号", required = true) String djxh,
                                     @RequestParam("nds[]") @ApiParam(name = "nds[]", value = "最近三年数组", required = true) String[] nds) {

        logger.info("请求->查询财务报表数据->输入参数【djxh:" + djxh + ",nds:" + nds + "】");

接收的时候,@RequestParam不能用nds接收,要用nds[]接收

你可能感兴趣的:(Spring boot 接收数组)