jeudi 8 juin 2017

Spring MVC passing model as dto to form?

I have question about passing my entity models to controllers and after that to form on view, where user can populate necessary data.

So right now it is like that :

Controller

User user = new UserModel();
model.add("user", user);

View

Form thing to populate values 

And the question is: I want to not pass entity itself but DTO for safety purposes. Because DTO must be Immutable without setters, How then I will set those mandatory fields on view ? I need to make something like POJO to just passing data? Then After population of data, convert POJO to entity with assembler and save it in my database? Or there are other ways to do that ?

Aucun commentaire:

Enregistrer un commentaire