gpt4 book ai didi

java - 如何在retrofit2中设置参数列表

转载 作者:行者123 更新时间:2023-12-02 12:42:30 24 4
gpt4 key购买 nike

我在retrofit2中设置参数时遇到问题

我想设置group_iduser_id

public class ChatRequest {

private String group_id;
private List<Userbean> users;

public String getGroup_id() {
return group_id;
}

public void setGroup_id(String group_id) {
this.group_id = group_id;
}

public List<Userbean> getUsers() {
return users;
}

public void setUsers(List<Userbean> users) {
this.users = users;
}


public static class Userbean {


private int user_id;

public int getUser_id() {
return user_id;
}

public void setUser_id(int user_id) {
this.user_id = user_id;
}
}
}

和我的改造

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();
ChatRequest chatRequest = new ChatRequest();
chatRequest.setGroup_id("dsdfjlds9u");
chatRequest.setUsers ///// How to set user_id = 8(int)

如何设置user_id=8??

我不知道如何设置

感谢您的帮助!

最佳答案

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();

ChatRequest chatRequest = new ChatRequest();
chatRequest.setGroup_id("dsdfjlds9u");
UserBean userBean = new UserBean();
userBean.setUser_Id(8);
chatRequest.setUsers(Collections.singletonList(userBean));

关于java - 如何在retrofit2中设置参数列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44885385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com