Java MVC Model 2 Architecture Examples?

Can someone send or point me towards a clear example of the implementation of the Model 2 architecture from scratch ?

The following is a detailed description of Model 2 taken from this page .

The Model 2 architecture for designing JSP pages is actually a Model View Controller (MVC) applied to web applications. Therefore, the two terms can be used interchangeably in the world of the Internet. MVC originated in SmallTalk and has since made its way into the Java community. The architecture of Model 2 and its derivatives are the cornerstones of all serious and industrial robust web applications developed in the real world. Therefore, it is important that you fully understand this paradigm. Figure 1.2 shows the architecture of Model 2 (MVC).

The main difference between model 1 and model 2 is that in model 2 the controller processes the user request instead of another JSP. The controller is implemented as a servlet. The following steps are performed when the user submits a request.

  • The Servlet controller processes the user request. (This means that the hyperlink in the JSP must point to the controller servlet).
  • The Servler Servlet then creates instances of the corresponding JavaBeans based on the request parameters (and, optionally, also based on the session attributes).
  • A servlet controller, which by itself or through a controller assistant communicates with the middle tier or directly with the database to retrieve the necessary data.
  • The controller installs the resulting JavaBeans (same or new) in one of the following contexts: query, session, or application.
  • The dispatcher then sends a request for the next view based on the request URL.
  • The view uses the resulting JavaBeans from step 4 to display the data. Note that there is no presentation logic in the JSP. The only JSP feature in Model 2 architecture is to display data from a set of JavaBeans in a query, session, or application area. MVC Example http://www.java-samples.com/images/model2architecture.jpg
+4
source share
4 answers

I like Bear Bibeault article from a few years ago. High level explanation, but very clear.

This is his implementation of the MVC "framework". I learned a lot by going through it:

Bear Bibeault Frontman

+2
source

I would download Spring and check out some Spring examples. Also take a look at this tutorial.

+1
source

Maybe Struts 1 (with tiles) will be easier to grock than Spring if you want to see how MVC works in a Java web application. Ignoring all the Struts tags, you get actions (that are invoked by the Struts servlet), a JSP, and a configuration file or two to link them together. A lot of information on the Internet.

0
source

Source: https://habr.com/ru/post/1285970/


All Articles