Well, they are exactly similar, except that *.servlet.*
classes are tailored for classical web applications based on servlets, while *.portlet.*
one are specially tailored 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 underlying view abstractions and integration technology.
But a portlet in much different from a servlet. You could find references on the JSR-168 and a nice presentation on What Is a Portlet - O'Reilly Media. Here are some extracts from the latter :
Portlets are web components--like servlets--specifically designed to be aggregated in the context of a composite page. Usually, many portlets are invoked to in the single request of a portal page. Each portlet produces a fragment of markup that is combined with the markup of other portlets, all within the portal page markup.
[Windows for different applications are] developed independently of each other. The developer of the news portlet will create an application and pack it into a .war file. Then the administrator of the portal server will install this .war file on the server and create a page. In the next stage, every user will choose which applications he wants on his page.
For that reason, Spring portlet classes are very different from portlet ones, even when they present same interface. The main way in which portlet workflow differs from servlet workflow is that the request to the portlet can have two distinct phases: the action phase and the render phase. The action phase is executed only once and is where any backend changes or actions occur, such as making changes in a database. The render phase then produces what is displayed to the user each time the display is refreshed.
TL/DR : So *portlet*
classes have been specialy designed to present a similar interface to the developper (same as *servlet*
) but are quite different under the hood and must not be used in classical (servlet) SpringMVC applications.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…