入参时间格式化
@JsonFormat(pattern = "yyyyMMdd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyyMMdd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
入参参数转换提取
请求:
{
"condition":{
"area":"1111",
"name":"",
"order_id":""
},
"page":{
"pageSize":10,
"currentPage":1
}
}
public String test(@RequestBody JSONObject jsonObject){
JSONObject page = jsonObject.getJSONObject("page");
int currentPage = page.getInteger("currentPage");
int pageSize = page.getInteger("pageSize");
JSONObject condition = jsonObject.getJSONObject("condition");
// condition里的内容自动填值到对应的pojo类中
transiSubnet = JSONObject.toJavaObject(condition,xxx.class);
入参数组 转换未List
请求报文
{
"id":["11","22","33","44","55"]
}
JSONArray array = query.getJSONArray("id");
// 转换成数组
List<String> ids = array.toJavaList(String.class);
参数对外名称修改,外部入参的字段为 tilte, 而不是 Title
@JsonProperty("title")
private String Title;