简体   繁体   中英

Spring REST, user ressource and password

I m actually creating my first little Spring application, a Rest webservice and I m facing a problem.

In fact, I have a ressource at /users and I dont want people to get the password.

My User object contains a password field.

So what can I do to bypass this ? Can I hide the field ? Can I do something better to manage this ?

Thanks for advance

Assuming that you are returning JSON from your webservice you could mark the password field/getter with @JsonIgnore annotation, that way it wouldn't be included in the JSON returned by your controller.

If you are returning XML and your object is annotated with JAXB annotations, you can use @XmlTransient annotation to achieve the same result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM