标签:return obj 定义 status 分享图片 bsp 成功 The res
一:单独创建一个类来表示返回结果
package com.jk51.commons.dto; /** * Created by Administrator on 2017/6/13. */ public class PacketHead { public static final String STATUS_SUCCESS = "OK";//成功 public static final String STATUS_ERROR = "ERROR";//成功 private String status; //返回状态 private String msg; //返回信息 public PacketHead() { status = STATUS_SUCCESS; } public PacketHead(String status, String result) { this.status = status; this.msg = msg; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } }
二:创建返回类ResultData 以后controller可以统一采用此类作为返回结果
/** * 返回结果封装 * Created by Administrator on 2018/7/3. */ public class ResultData extends PacketHead{ private Object data; public ResultData(){ this.setStatus(STATUS_SUCCESS); } public Object getData() { return data; } public void setData(Object data) { this.data = data; } }
用法如图实例
标签:return obj 定义 status 分享图片 bsp 成功 The res
原文地址:https://www.cnblogs.com/chenpt/p/9257915.html