我有使用String的方法。我想使用WebClient在主体中发送此字符串。
一块块下面。
public String JsonMethod(User user) {
String jsonUserRegister = "{\n" +
" \"variables\":\n" +
" {\n" +
" \"user\": \n" +
" {\n" +
" \"value\":\n" +
" {\n" +
" \"username\": \"" + user.getUsername() + "\",\n" +
" \"email\": \"" + user.getEmail() + "\",\n" +
" \"address\": \"" + user.getAddress() + "\",\n" +
" \"number\": \"" + user.getNumber() + "\"\n" +
" } }\n" +
" }\n" +
"}";
return jsonUserRegister;
}
WebClient webClient;
public Mono<Boolean> registerUser(User user) {
return webClient
.post()
.uri(URL + ":" + PORT + REST_API_REGISTER_PROCESS)
.contentType(MediaType.APPLICATION_JSON)
.body(WHAT SHOULD BE THERE?)
我不知道如何从方法到.body调用此字符串