Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot spring引导模型属性对象,带有导致400错误的字符串列表_Spring Boot_Spring Mvc_Swagger_Swagger Ui_Modelattribute - Fatal编程技术网

Spring boot spring引导模型属性对象,带有导致400错误的字符串列表

Spring boot spring引导模型属性对象,带有导致400错误的字符串列表,spring-boot,spring-mvc,swagger,swagger-ui,modelattribute,Spring Boot,Spring Mvc,Swagger,Swagger Ui,Modelattribute,我有一个控制器,它将参数作为模型属性类传入。我使用的是SpringBoot(MVC)和Swagger API。但是,当我在Model属性中的字符串列表中使用多个项目发出请求时,我会得到一个400状态错误 控制器 @ApiOperation(value = "Equipment model data", notes = "Insert the Equipment model data") @PostMapping("/")

我有一个控制器,它将参数作为模型属性类传入。我使用的是SpringBoot(MVC)和Swagger API。但是,当我在Model属性中的字符串列表中使用多个项目发出请求时,我会得到一个400状态错误

控制器

    @ApiOperation(value = "Equipment model data", notes = "Insert the Equipment model data")
    @PostMapping("/")
    public Mono<EquipmentModelDTO> postEquipmentModel(@ModelAttribute EquipmentParam equipmentParam) {
        EquipmentModelDTO equipmentModelDTO = equipmentModelService.saveEquipmentModel(equipmentParam, userId);

        aduitLogService.saveAuditLog("equipmentModel", "/", ActionTypes.INSERTED, equipmentParam.toString(), userId);

        return Mono.justOrEmpty(equipmentModelDTO);
    }
@ApiOperation(value=“设备型号数据”,notes=“插入设备型号数据”)
@邮戳(“/”)
公共Mono postEquipmentModel(@ModelAttribute EquipmentParam EquipmentParam){
EquipmentModelDTO EquipmentModelDTO=equipmentModelService.saveEquipmentModel(equipmentParam,userId);
aduitLogService.saveAuditLog(“设备模型”,“/”,ActionTypes.INSERTED,设备参数.toString(),用户ID);
返回Mono.justOrEmpty(设备型号dto);
}
模型

@数据
@ApiModel(description=“设备模型参数”)
公共级设备参数{
@ApiModelProperty(value=“设备型号名称”,必需=false,示例=”)
私有字符串设备模型名;
@ApiModelProperty(value=“Type Code”,必需=false,示例=”)
私有字符串类型码;
@ApiModelProperty(value=“ManufactureCode”,必需=false,示例=”)
私有字符串制造代码;
@ApiModelProperty(value=“位置代码列表”,必需=false)
私有列表位置cds=newarraylist();
@ApiModelProperty(value=“构建年份”,必需=false,示例=”)
私人建筑年;
@ApiModelProperty(value=“Description”,required=false,example=”“)
私有字符串描述;
}

通过使用RequestBody而不是RequestParam传入参数,修复了此问题
@Data
@ApiModel(description = "Equipment Model Parameter")
public class EquipmentParam {

    @ApiModelProperty(value = "Equipment Model Name", required = false, example = "")
    private String equipmentModelName;

    @ApiModelProperty(value = "Type Code", required = false, example = "")
    private String typeCode;

    @ApiModelProperty(value = "ManufactureCode", required = false, example = "")
    private String manufactureCode;

    @ApiModelProperty(value = "Position Code list", required = false)
    private List<String> positionCds = new ArrayList<String>();

    @ApiModelProperty(value = "Built Year", required = false, example = "")
    private int builtYear;

    @ApiModelProperty(value = "Description", required = false, example = "")
    private String description;
}