Skip to content

Instantly share code, notes, and snippets.

View zwdgit's full-sized avatar

Dev Zwd zwdgit

View GitHub Profile
@zwdgit
zwdgit / ServerResponse
Last active July 24, 2018 03:11
通用响应对象
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
/*
JsonSerialize 注解的作用就是:保证序列化 json 的时候,如果是 null 的对象,key 也会消失。
部分响应对象不需要将字段全部返回前端,例如‘失败’的时候只需要返回 status 和 msg ,Data 是不需要返回的,
此时返回前端时,只有一个 key ,而 value 为空,所以需要进行配置,将 value 为空的字段进行忽略
*/
public class ServerResponse<T> implements Serializable {
private int status;
private String msg;
private T Data;