前言
SSM封装表现层响应数据
封装ResponseResult类
src/main/java/com/pojo/ResponseResult.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| package com.pojo;
public class ResponseResult {
Integer code; String msg; Object data;
public ResponseResult() { }
public ResponseResult(Integer code, String msg) { this.code = code; this.msg = msg; }
public ResponseResult(Integer code, String msg, Object data) { this.code = code; this.msg = msg; this.data = data; }
public Integer getCode() { return code; }
public void setCode(Integer code) { this.code = code; }
public String getMsg() { return msg; }
public void setMsg(String msg) { this.msg = msg; }
public Object getData() { return data; }
public void setData(Object data) { this.data = data; } }
|
封装Code类
src/main/java/com/pojo/ResponseCode.java
1 2 3 4 5 6 7 8 9 10 11 12 13
| package com.pojo;
public class ResponseCode { public static final Integer SAVE_OK = 20011; public static final Integer DELETE_OK = 20021; public static final Integer UPDATE_OK = 20031; public static final Integer GET_OK = 20041;
public static final Integer SAVE_ERROR = 20010; public static final Integer DELETE_ERROR = 20020; public static final Integer UPDATE_ERROR = 20030; public static final Integer GET_ERROR = 20040; }
|
完成
参考文献
哔哩哔哩——黑马程序员