public class ResultCode { // 成功状态码 public static final int SUCCESS = 1; // -------------------失败状态码---------------------- // 参数错误 public static final int PARAMS_IS_NULL = 10001;// 参数为空 public static final int PARAMS_NOT_COMPLETE = 10002; // 参数不全 publ
在Java里很容易做到自定义有状态码和状态说明的枚举类例如: public enum MyStatus { NOT_FOUND(404, "Required resource is not found"); private final int code; private final String msg; private MyStatus (int code, String msg) { this.code= code; this.msg = msg; } public int get