使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre

简介: 使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre

1、

必须添加@Data

result类:

package worldtolingyidianke.file.bean;
 
 
 
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Data;
 
//统一响应结果
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {
    private Integer code;//业务状态码  0-成功  1-失败
    private String message;//提示信息
    private T data;//响应数据
 
    //快速返回操作成功响应结果(带响应数据)
    //快速返回操作成功响应结果(带响应数据)
    public static <E> Result<E> success(E data) {
        return new Result<>(0, "操作成功", data);
    }
 
    //快速返回操作成功响应结果
    public static Result success() {
        return new Result(0, "操作成功", null);
    }
 
    public static Result error(String message) {
        return new Result(1, message, null);
    }
}
 
相关文章
|
7月前
|
SQL IDE Java
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
80 0
|
7月前
|
druid Java
Error attempting to get column ‘createTime‘ from result set的异常
Error attempting to get column ‘createTime‘ from result set的异常
449 0
|
SQL Java 数据库连接
attempted to return null from a method with a primitive return type
attempted to return null from a method with a primitive return type
224 0
|
前端开发
springboot05、封装返回结果集{state:““msg:““result:null}
springboot05、封装返回结果集{state:““msg:““result:null}
160 0
springboot05、封装返回结果集{state:““msg:““result:null}
|
Python
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
1544 0
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.