Spring MVC | Code Factory

Donate : Link

Medium Blog : Link

Applications : Link

This image has an empty alt attribute; its file name is image-1.png

Spring Tutorial Index Page: Link

  • Spring MVC Supports
    • Form Backup Support (Spring Tags)
      • On form submission data are stored in Bean and validate there if there is any error found then it will print error on model page along with error messages and correct data as well.
    • Controllers (Multi Action Controllers, Multiform Controller Support)
    • Validation Support
    • I18N Support
    • Interceptors
    • ViewResolvers
    • Exception Handling
  • If front controllers it is JSP then you can call that model as JSP Model 1.
  • If front controllers it is Servlet then you can call that model as JSP Model 2.
  • If you can go through Filters then you can call that model as JSP Model 3.
  • If you can go through Tag Support then you can call that model as JSP Model 4.
  • * Recommended models are 2 and 3. By using JSP Model 2 architecture Apache people design Struts 1X, Spring people design Spring MVC, JSF also designed by using Model 2 and using JSP Model 3 architecture Apache people design Struts 2X.
  • * In Spring MVC the Front Controller name is DispatcherServlet.
  • In Struts 1X Front Controller name is ActionServlet.
  • In Struts 2X Front Controller name is FilterDispatcher and StrutsPrepareAndExecuteFilter.
  • In JSF Front Controller name is FacesServlet.
  • In Spring MVC we can load xml file 3 ways
  1. Using <servlet-name>
    Check examples from Spring MVC – Handler Mapping.
  2. Using <init-param> or config param
  3. Using <context-param>
  • Spring MVC Controller Hierarchy
  • Handler Classes
Handler mappingHow it maps requests to controllers
BeanNameUrlHandlerMappingMaps controllers to URLs that are based on the controllers’ bean name.
SimpleUrlHandlerMappingMaps controllers to URLs using a property collection defined in the Spring application context.
ControllerClassNameHandlerMappingMaps controllers to URLs by using the controllers’ class name as the basis for the URL.
CommonsPathMapHandlerMappingMaps controllers to URLs using source-level metadata placed in the controller code. The metadata is defined using JakartaCommons Attributes.
  • View Resolvers
  1. InternalResourceViewResolver
  2. XmlViewResolver
  3. ResourceBundleViewResolver
  4. TilesViewResolver
  • * Dispatcher Servlet
    • Request, Response are goes into Handler Mapping and based on the action (Ex. /login.html) it will return Controller name.
    • In Controller, code will execute and data passed with ModelAndView.
    • From ModelAndView, View Resolver will find page for view based on Location of view page (WEB-INF/jsp/output) and Extension of viewpage (.jsp). Using prefix and suffix.
    • View Resolver send view name (success.jsp) to View and it will render to the User.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s