springmvc通用返回json封装类(基于jackson) 作者:马育民 • 2020-10-03 13:06 • 阅读:10199 ``` package com.jsoft.model; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class JsonResult { /** * code: * 0:表示成功 * 100: 表示注册失败 * 101:电话号重复 * 200:登录失败 * * 100000:发生错误 */ protected int code; private String msg; protected T data; public JsonResult() { } public JsonResult(int code,String msg){ this.code=code; this.msg=msg; } public JsonResult(int code,T data){ this.code=code; this.data=data; } public JsonResult(int code,String msg,T data){ this.code=code; this.msg=msg; this.data=data; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public T getData() { return data; } public void setData(T data) { this.data = data; } } ``` 原文出处:http://malaoshi.top/show_1EF6N40HjkEY.html