I faced this question in an interview. Please clarify.
Question is as follows-
We are having some small spring web applications in which List of Employees and some other info needs to be displayed on page.
So he asked how will you achieve it.
Acc to me we can create a new class (for example EmployeeInfo) which will contain a List of Employees and some other class level variables to accommodate the extra info that need to be displayed.
After populating the EmployeeInfo class, we will add it to Model object. And in jsp we can easily get the details.
The question is what is model in this Employee class or EmployeeInfo class that we added to Model object.?
And please clarify what Model is in MVC? Is it just to transfer data from Controller to View?
In an MVC pattern. Model is anything that represents your data. The Controller is responsible for business logic and the view is responsible for displaying the data. Generally the model is made up of POJOs that represent the application's data.. and nothing else. In your case you will have POJOs for Employee and EmployeeInfo. If you are using JPA or any other kind of ORM for your data access, it;s not uncommon to annotate the pojos with annotations that tell the DAO how to map the POJO to the database schema.