Reputation: 1230
I'm developing a website using spring mvc , and I have to specify the conception of my application.
I have these components in it :
Is the architecture of an application which have these components 'multilayered' or 'mvc',and if it's mvc application I want to know if the model contains only the domain's objects or in addition to this, it contains also service,repository and DTO .
Upvotes: 2
Views: 145
Reputation: 48267
Spring MVC is the presentation layer of a server-generated-html n-tier application. N can be one.
It includes the View layer, which are usually JSPs or some templating system.
It also includes Controllers, which are classes that handle HTTP requests and help generate HTTP responses. The role of the controller is to load the correct model and choose the correct view.
Models are maps of POJOs. They need not be JPA entity objects, but often are. A model can contain a list of POJOs of the same type, or several POJOs of different types. A model is simple a collection of all the data that a view needs to do its thing.
For example, you could have a very basic POJO that calculates the first payment amount on a loan, based on the interest rate and principal. You require the interest rate and principal amount from the user, and they enter it on an HTML form. They press submit and are shown the first payment amount.
In this case you would have a controller that handles the initial GET request, creates a new instance of your POJO, adds it to the model map, and returns the name of the view.
It would also have a method to accept a POST request, load the model, do the calculation, and return the POJO and probably a new view.
As you can see, you do not need database access in an MVC application.
You can include JPA entities in your models, or not, or use them together with non-JPA POJOs.
Upvotes: 1