The pit of SpringBoot Controller JSON serialization hump

When the attribute in the entity class is defined as the first word consisting of only one letter, such as rBack 

The serialized JSON will become rback. The current station passes the parameter rBack to the background, and you will find that the rBack attribute cannot get a value

Solution:

Add @JsonProperty annotation to the get method of the field

If you use lombok, add @JsonProperty annotation to the field

public class Work{
    private String rBack;
    
    @JsonProperty("rBack")
    public String getrBack() {
        return rBack;
    }

    public void setrBack(String rBack) {
        this.rBack= rBack;
    }
}

 

Guess you like

Origin blog.csdn.net/java_cxrs/article/details/105850597