How spring MVC differ from other Framework
Techno Kryon |
Introduction:
Spring MVC framework is associated
with three layers that are model, view, and controller. This framework provides
a decoupled way of web
application development.
Spring MVC differs
from other Framework:
Spring MVC is a simple concept
like Dispatcher Servlet, ModelAndView, and ViewResolver. It makes easy to
develop Web
Applications. It is similar to struts framework (developed an MVC related
Web application).
It specifies each and every dependency
separately. We need lot of configuration
to be written to achieve the same. But the spring boot was packaged as a jar
with an embedded server by default.
The most favored in it are classes
annotated with @Controller. When the user sends the request it is accepted by a
Dispatcher Servlet.
Spring MVC controller is when you
make a request to an application, a controller is responsible for returning the
response to the request validations and transformations. It fetches the data
from the database and then create a model object for that. The controller can
also perform one or more actions. The controller action can return different
type of action results to a particular request based on the request mapping, HTTP
methods or data format.
Use of Dispatcher
Servlet in Spring MVC:
When we use Spring MVC all the requests go
through to a single servlet like dispatcher servlet. It is the front controller
for spring MVC framework. Dispatcher servlet receives all request and transfers
them to all others components of the application.
Dispatcher
servlet uses DefaultAnnotationHandlerMapping
and BeanNameUrlHandlermapping by
default. When the target is identified, the dispatcher servlet sends the request
to it. The Controller works according to the request and return back to the dispatcher
with model and determines the view that will display the result. Finally, the dispatcher
servlet returns the result object back to the client side.
Pitfall for using
Spring MVC:
- When we are using the Spring MVC framework, we need to the configuration for a component scan, view resolver, dispatcher servlet, web jars and other things.
- No clear guidance about spring MVC on cross-site request forgery attacks and cross-site scripting attacks in Spring MVC documentation and suffers for several security holes.
- Large configuration problem using Spring MVC.
- More than one View resolver, handler and controller are used in Spring MVC.
Comments
Post a Comment