前端传输json数据,后端如何用枚举接受

如图

 

需要加上枚举类中加上此方法

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
        public static GreenBeltMode getByValue(Integer code) {
            if (code == null) return null;
            return Arrays.stream(GreenBeltMode.values()).filter(i -> i.getCode() == code.intValue()).findAny().orElse(null);

        }

 

 

 

 

 

posted @ 2022-02-24 15:45  绿茶汤圆  阅读(239)  评论(0)    收藏  举报  来源