当前位置:网站首页>Custom JSON return data
Custom JSON return data
2022-07-28 05:39:00 【jekyhu】
- Back end development , Use spring The official return data agreement is not unified ⼀, Missing business status code .
- Thus, you can define the status code by yourself , Achieve unity with the front end .
public class JsonData {
private int code;
private Object data;
private String msg;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public JsonData(){}
public JsonData(int code, Object data){
this.code = code;
this.data = data;
}
public JsonData(int code, Object data, String msg){
this.code = code;
this.data =data;
this.msg = msg;
}
public static JsonData buildSuccess(Object data){
return new JsonData(1,data);//1 On behalf of success
}
public static JsonData buildError(String msg){
return new JsonData(0,"",msg);//0 For failure
}
public static JsonData buildError(String msg,int code){
return new JsonData(code,"",msg);// Custom status code , Unified with the front end
}
}

边栏推荐
- CentOS7安装MySQL5.7
- Digital twin technology creates visual application of smart mine
- SSM project quick build project configuration file
- FusionGAN代码学习(一)
- openjudge:校园食宿预订系统
- Invalid bound statement (not found): com.exam.mapper.UserMapper.findbyid
- Feignclient calls the get method and reports an error resultvo{result= unknown exception. Exception details: request method 'post' not supported
- 正则表达式
- Advanced multi threading: the underlying principle of synchronized, the process of lock optimization and lock upgrade
- openjudge:大小写字母互换
猜你喜欢

visio如何快速生成相同的图案,生成图像矩阵

Digital twin solutions inject new momentum into the construction of chemical parks

冶金物理化学复习 --- 液 - 液相反应动力学

多线程进阶:synchronized底层原理,锁优化、锁升级的过程

JUC notes

MySQL adds sequence number to query results

VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard

Tomato timing dimming table lamp touch chip-dlt8t10s-jericho

You must configure either the server or JDBC driver (via the ‘serverTimezone)

ResNet结构对比
随机推荐
openjudge:万年历
yandex robots txt
JUC笔记
ByteBuffer. Position throws exception illegalargumentexception
Pytorch uses maxpool to realize image expansion and corrosion
【MySQL】MySQL时区问题、数据库时间相差8小时问题解决
FeignClient 调用GET 方法报错 ResultVO{result=未知异常,异常详情:Request method ‘POST‘ not supported
Learning of image enhancement evaluation index -- structural similarity SSIM
Long和Integer如何进行比较,为什么报错
Oracle创建表、删除表、修改表(添加字段、修改字段、删除字段)语句总结
ECCV22 最新54篇论文主图整理
repackag failed: Unable to find main class
JVM篇 笔记4:内存模型
Mybats foreach multi select query, index loop, and cancel the and/or tag
ssm项目快速搭建项目配置文件
冶金物理化学复习 --- 复杂反应的速率方程
项目中问题合集
Mabtis (I) basic use of framework
RESNET structure comparison
block yandex bot