0
点赞
收藏
分享

微信扫一扫

入参是集合怎么传?(借用ArrayList)

yongxinz 2022-06-05 阅读 26

应该是这么个形式

{"collectionDtoList":[{"collectionType":1,"typeId":3}]}

使用javabean进行解析对应

import java.util.List;

public class CancelCollectBean {

private List<CollectionDtoListDTO> collectionDtoList;

public List<CollectionDtoListDTO> getCollectionDtoList() {
return collectionDtoList;
}

public void setCollectionDtoList(List<CollectionDtoListDTO> collectionDtoList) {
this.collectionDtoList = collectionDtoList;
}

public static class CollectionDtoListDTO {
private int collectionType;
private int typeId;

public int getCollectionType() {
return collectionType;
}

public void setCollectionType(int collectionType) {
this.collectionType = collectionType;
}

public int getTypeId() {
return typeId;
}

public void setTypeId(int typeId) {
this.typeId = typeId;
}
}
}

参数组装

List<CancelCollectBean.CollectionDtoListDTO> collectionDtoList = new ArrayList<>();
CancelCollectBean.CollectionDtoListDTO collectionDtoListDTO = new CancelCollectBean.CollectionDtoListDTO();
collectionDtoListDTO.setCollectionType(1);
Log.e("wy", "156onItemClick: "+records.get(position).getTypeId() );
collectionDtoListDTO.setTypeId(records.get(position).getTypeId());
collectionDtoList.add(collectionDtoListDTO);


举报

相关推荐

0 条评论