How to use Jackson:
//The first method is to use @JsonIgnore annotation to annotate on the attribute, ignore the specified attributepublic class PropertyDTO { @JsonProperty("disable") private Integer disable; @JsonProperty("placeholder") private String placeholder; //Use @JsonIgnore annotation, ignore this property, the front-end will not get the property @JsonIgnore private String validate; } //The second way is to use @JsonIgnoreProperties to annotate on the class, and you can ignore the properties of the specified collection@JsonIgnoreProperties({"validate"}) public class PropertyDTO { @JsonProperty("disable") private Integer disable; @JsonProperty("placeholder") private String placeholder; private String validate; }
Note:
public class PropertyDTO { @JsonProperty("disable") private Integer disable; @JsonProperty("placeholder") private String placeholder; @JsonProperty("validate") @JsonIgnore private String validate; }
Use simultaneously@JsonProperty
and@JsonIgnore
When it may cause@JsonIgnore
If it fails, the front-end still gets this attribute.
When using fastjson:
use@JSONField(serialize = false)
annotation
This is the article about the method of ignoring a certain attribute in the entity class and not returning to the front-end in SpringBoot. This is the end. For more related SpringBoot attributes that do not return to the front-end content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!