我有一个字符串,单词之间有 3 个空格,但在 POJO 类中,当我将值设置为字符串时,它会自动减少 3 个空格,并且只有一个空格。无论如何,我们是否可以使用保留字符串中的所有 3 个空格POJO getter 和 setter
package Pojo;
import com.fasterxml.jackson.annotation.JsonInclude;
public class PojoSample {
@JsonInclude(JsonInclude.Include.NON_NULL)
private String next;
public String getNext() {
return next;
}
public void setNext(String next) {
this.next = next;
}
}
在上面的代码中,如果我将值
"abcd efgh"
设置为 var 令牌,我将得到此值 "abcd efgh"
但我想保留所有三个空格,我该怎么做?我可以使用任何注释或正则表达式吗?
public PojoSample setAllData(字符串下一个){
PojoSample Pos = new PojoRCSTransactions();
Pos.setNext(next);
return Pos;
}
这就是我设置 Next 值的方式,然后下面的代码显示了我如何在 API 调用中使用它
Response response = Trans.postTransactions(token);
下面的代码进行实际调用
RestAssured.baseURI = baseURL;
System.out.println(baseURL);
String postrcsTransactions = "/cards/transactions";
Response response = given().relaxedHTTPSValidation().urlEncodingEnabled(true)
.filter(logFilter)
.header("Authorization", token)
.header("abcd","header value")
.body(rcsTransactionsData)
.when()
.post(postrcsTransactions);
System.out.println(response);
return response;
}