使用@ResponseBody
封装成json格式
一、返回Json
package com.kude.common;
/**
* @Author:xiaoming
* @Date: 2019/7/25 11:02
* @Description
*/
public class ResponseMessage<T> {
private String code;
private T data ;
private String msg;
public ResponseMessage(String code, T data, String msg) {
this.code = code;
this.data = data;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "ResponseMessage{" +
"code='" + code + '\'' +
", data=" + data +
", msg='" + msg + '\'' +
'}';
}
public ResponseMessage() {
}
}
示例:
{
"code": "0",
"data": {
"img": "1111",
"username": "张四",
"sex": "男",
"kidUser": "蓝天白云幼儿园",
"tel": null,
"addrsss": null,
"token": "1564045745743"
},
"msg": "登陆成功"
}