What's the difference in org.springframework.web.servlet.ModelAndView vs org.springframework.web.portlet.ModelAndView

Can anyone tell the difference between

org.springframework.web.servlet.ModelAndView

      

and

org.springframework.web.portlet.ModelAndView

      

both ModelAndViews have nearly the same methods. The major difference from notification was that when I added the object to org.springframework.web.portlet.ModelAndView

, the object was unable to reach the view. In the view, the added object was null

. Do you know of any other significant differences? !! Please add your information here :)

In the general case, the question of the difference in

org.springframework.web.servlet.*;
org.springframework.web.portlet.*;

      

+3


source to share


1 answer


Well, they are exactly the same, except that the classes are *.servlet.*

adapted for classic servlet-based web applications, and *.portlet.*

specifically for JSR-168 portlets.

This is a deliberate choice from Spring: as much as possible, the Portlet MVC framework is a mirror image of the Web MVC framework, and also uses the same basic abstractions and integration technology.

But a portlet is very different from a servlet. You can find links to JSR-168 and a nice presentation on What is a Portlet - O'Reilly Media . Here are some excerpts from the latter:

Portlets are web components, such as servlets, specifically designed to aggregate in the context of a composite page. Typically, many portlets are called in a single portal page request. Each portlet creates a piece of markup that is combined with the markup of other portlets, all in the markup of the portal page.



[Windows for Different Applications] are developed independently of each other. The developer of the news portlet will create the application and package it into a .war file. The portal server administrator will then install this .war file on the server and create the page. In the next step, each user will choose which applications they want on their page.

For this reason, Spring portlet classes are very different from portlets, even when they represent the same interface. The main way a portlet workflow differs from a servlet workflow is that a request to a portlet can have two distinct phases: an action phase and a render phase. The action phase is performed only once and occurs when there are any changes or actions on the backend, such as making changes to the database. The render phase then produces what is shown to the user every time the display is refreshed.

TL / DR: So the classes *portlet*

were specifically designed to present a similar interface to the developer (same as *servlet*

) but are completely different under the hood and should be used non- classic (servlet) SpringMVC applications.

+3


source







All Articles