[JAVA] Flux de contrôleur de vue du modèle de ressort

​ Spring Web MVC Framework :

Spring MVC framework is a well designed framework, that you can use to develop web applications using MVC design pattern. There are many benefits to let you move towards Spring framework to implement your web application and it follows same principles as other Spring framework modules.

Benefits Of Spring Web MVC :

Since Spring MVC framework is designed like any other Spring module, developer need not spend any extra time to learn it. Since all the layers are independent of each others, unit testing can be easier. Spring framework doesn’t force you to follow any pattern, or implementations to write your business logic. So it gives developer flexibility to implement or integrate any other design pattern to suffice his needs. Spring provides good separation flexibility between Controller, Service and Data access layers. Spring provides you with a tag library that is simple and yet very powerful. View side you can integrate with any UI framework like JSF, Velocity, Freemarker etc. Project setup with Spring is quite easy unlike any other web framework, and it will be light weight since everything is based on POJO. Supports Annotation based programming along with XML, which makes development faster and cleaner. Other built in Sping frameworks like JDBC, Form Validation can be easily integrated.

Spring MVC Architecture flow:

Any incoming request that comes to the web application will be sent to Front Controller (Dispatcher Servlet) Front Controller decides to whom (Controller) it has to hand over the request, based on the request headers. Controller that took the request, processes the request, by sending it to suitable service class. After all processing is done, Controller receives the model from the Service or Data Access layer. Controller sends the model to the Front Controller (Dispatcher Servlet). Dispatcher servlet finds the view template, using view resolver and send the model to it. Using View template, model and view page is build and sent back to the Front Controller. Front controller sends the constructed view page to the browser to render it for the user requested.

Spring Web MVC Concept:​

Spring Controller: Spring provides many types of controllers, developer has to choose one based on his requirement whether you have form in your UI, if you have wizards, etc. Below is the class diagram showing partial list of controllers.,

Model and View : ModelAndView is part of org.springframework.web.servlet package. Controller returns the instance of ModelAndView and Model values are placed in object in the form of a map.

Command Object :

This is the object that will be passed once if user submits any form in the front UI, with all the form fields. The same object will be passed to validator to validate the content to check whether it is filled as we need, and it is simple java bean style representation.

Validator : Validator is used to validate the form data received by the controller. Custom validator for the form can be created by implementing the interface org.springframework.validation.Validator It has two methods validate and errors, to validate command object passed and errors to store the errors. Spring Tag Library : Spring bind type library is very simple and powerful. It is generally used in the JSP pages using <spring: bind> tag, used to bind form fields to command object.​

​ Related blog:

Spring data jpa with maven

Spring boot interview questions

Recommended Posts

Flux de contrôleur de vue du modèle de ressort
Relation entre le contrôleur et la vue
Flux jusqu'à la sortie des données de la table à afficher avec Spring Boot
Relation de vue du contrôleur de routage des rails
Mémo de méthode de contrôleur de démarrage à ressort
Contrôleur de cadre de test Spring avec Junit