NutzCN Logo
问答 @Param 获取不到{"id":"",arrays:["a":"1","b":"1"]}这种类型对应的dto,只能用map获取
发布于 33天前 作者 xiaomo 127 次浏览 复制 上一个帖子 下一个帖子
标签:

对应的dto如下:

@NoArgsConstructor
@Data
public class BridgeClimateDto {

    private String id;
    private List<ArraysBean> arrays;

    @NoArgsConstructor
    @Data
    public static class ArraysBean {
        private BigDecimal windspeed;
        private String winddirection;
        private BigDecimal airtemperature;
        private BigDecimal humidity;
        private BigDecimal pressure;
        private BigDecimal visibility;
        private BigDecimal watervolume;
        private BigDecimal flowrate;
        private BigDecimal waterlevel;
        private BigDecimal currentvelocity;
    }
}

对应的获取的入口如下:

   @At
    @POST
    @AdaptBy(type=JsonAdaptor.class)
    public NutMap add(@Param("arrays") List<BridgeClimateDto.ArraysBean> arraysBeanList, @Param("..") BridgeClimateDto bridgeClimateDto) {
        log.info(Json.toJson(bridgeClimateDto,JsonFormat.compact()));
        log.info(Json.toJson(arraysBeanList,JsonFormat.compact()));
}

打出的日志如下:

4 回复
[INFO ] 18:02:50.774 com.zb.road.sensor.module.BridgeClimateModule.add(BridgeClimateModule.java:84) - {"id":"20202995","arrays":[{}]}
[INFO ] 18:02:50.775 com.zb.road.sensor.module.BridgeClimateModule.add(BridgeClimateModule.java:85) - [{}]

没有获取到对应的对象,但是通过Map是能获取到的

对应的参数是这样的

{"id":"20202995","arrays":[{"Windspeed":"0.00","Winddirection":"0","Airtemperature":"24.6","Humidity":"62.9","Pressure":"1001.2","Visibility":"0","Watervolume":"0","Flowrate":"0.000","Waterlevel":"0.000","Currentvelocity":"0.00"}]}

用pojo来收

这个BridgeClimateDto,就是一个Pojo,但是收不到,里面的list是空的呢。

添加回复
请先登陆
回到顶部