Evolution of Java Web Architecture

In the Java architectural pattern, we can abstract the MVC architectural pattern to the following structure:

  1. The View layer. View layer is UI layer, which can adopt technologies such as JSP,Structs,SpringMVC and so on
  2. The Controller layer. Controller represents the Controller layer and can be used by technologies such as Servlet/Filter and Spring
  3. The Service layer. The Service layer represents the core services layer, providing services to the upper layers of the architecture
  4. The DAO layer. DAO layer represents the data access layer, can use techniques such as JDBC and ORM framework (such as Spring JDBC, JPA, Hibernate, Mybatis, etc.)
  5. The Model layer. The Model layer represents JavaBean objects
  6. Utilities layer. The Utilities layer represents the common utility layer


It should be noted that other technologies, such as SOA,Nosql(Redis, Mongodb, etc.),MQ, etc., are not involved in this architectural abstraction model.

In addition, micro-service technology based on Springboot+Cloud is also not involved, because only MVC based architecture mode will be evolved here, and the specific JavaWeb architecture will be explained in later chapters.



Based on the above architectural abstraction model, we can divide the development of this architectural pattern into three stages:

Stage 1: Servlet stage

Stage 2: SSH(Spring+Structs+Hibernate) stage

Stage 3: SSM stage (Spring+SpringMVC+Mybatis) stage

In fact, there is also the fourth stage, the micro-services stage, which this article will not explain.

Phase 1: Servlet/Filter plays the role of controller

In this phase architecture pattern, Servlet/Filter plays the role of Controller, JSP plays the role of View, and Javabeans play the role of Model

The database access technology in this stage is JDBC of specific DB. Although this mode realizes the so-called MVC mode, it has many problems:

  1. Incomplete separation of front and rear ends. Due to the incomplete separation of the front and back ends of JSP technology, developers tend to nest Java code in JSP pages, requiring front-end developers to understand Java technology
  2. JSP page readability is poor, writing efficiency is low, despite the introduction of EL, JSTL and other technologies
  3. Sevlet/Filter as controller, facing stability, security tests (Servlet is not thread safe), etc
  4. Database access technology adopts traditional JDBC, resulting in too much redundant code

Of course, there are still many problems, and I will not list them here. To solve these problems, JavaWeb experts propose an architectural idea: modularity, abstraction, and specialization.

With this in mind, a number of specialized open source frameworks have sprung up, one of the best known composite frameworks being SSH.


Phase 2: SSH

  1. In this architecture mode, Controller adopts Spring framework technology, View adopts Structs framework technology, AND DB access technology adopts Hibernate framework technology
  2. From SSH, it is easy to see the specialization and refinement of the front and back ends and the evolution toward the framework, such as Structs for the front end framework and Spring for the back end framework


However, although SSH architecture solves the problems of Servlet/Filter architecture, realizing specialization, fine division of labor, modularization and abstraction, it has a relatively big problem: the framework is bulky and inflexible.

For example, although Hibernate can meet the business needs and solve the business, it is bulky and inflexibly, unable to realize the flexible configurable way well, and Structs are too bulky.

To solve this problem, JavaWeb experts have proposed another architectural pattern, namely SSM architectural pattern.



Stage 3: SSM

In this mode, Spring plays the role of Controller, SpringMVC plays the role of View (of course, for small systems, SpringMVC can be used directly), and Mybatis plays the role of DB access technology SSM architecture pattern

In the current JavaEE, it is a more popular development mode, but also one of the technology selection of most enterprises.

Of course, another design idea comparable to SSM is microservices (SpringBoot+ Cloud technology, etc.), which is not covered in this article.


2. Overview of SSM core framework

The Spring framework

Spring framework is currently the mainstream framework for JavaWeb development, and it can also be said that many enterprises must choose the framework, which roughly includes six modules.

  1. The Spring core container. This container is the core of the Spring framework and manages the creation, configuration, and management of beans in Spring applications
  2. Spring AOP. This module provides good support for aspect orientation and DI(dependency injection)
  3. Database access and integration module
  4. Web and remote call technology
  5. Instrument module
  6. The Test module



Mybatis framework

  1. According to Mybatis source code, it is abstracted into three layers: basic support layer, core processing layer and interface layer
  2. The basic support layers include: data sources, transaction management, logging, type conversions, caching, Bind, parsers, and more
  3. The core processing layer includes configuration parsing, configuration mapping, SQL parsing, SQL execution, result set mapping, plug-ins and so on
  4. The interface layer mainly provides JAVA apis