I have a simple spring boot application, my model contains 3 fields. and controller exposes 2 endpoints /e1 and /e2. what I want to achieve is that when /e1 is called I want to return all 3 fields from my model by when /e2 is called I was to return just 2 fields and hiding the 3rd field from it.
is there a way to do it and how this can be done ? thanks
First, you should always have 2 classes - entity and its dto presentation - even if they fields are very similar. This gives you:
You might need bean mapper for converting entity to DTO.
Two solutions you can try either of them ..
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.