On MVC, Spring MVC,

Source: Internet
Author: User

A typical Java web should look like this from the architecture:

1. The Web browser sends an HTTP request to the server, which is acquired by the Controller (servlet) and processed.

2. The Controller (Servlet) invokes the core business logic model section.

3. Model carries out database access operations and returns the result of the operation to model.

4. The controller gives the result of the business logic processing to the view (JSP) and dynamically outputs the HTML content.

5. Dynamically generated HTML content is returned to the browser display.

Spring MVC provides a dispacherservlet (which can be based on the servlet technology of Spring MVC), which encapsulates the functionality that is often implemented in a servlet in a Web application and provides a layer of public abstraction. Imagine something that corresponds to a Web request backend, such as:
    • URL mappings (corresponding to HTTP URLs and methods, what code should be called)
    • Permission validation (whether the current URL allows current user access)
    • Parameter resolution (how to get parameters from the servlet)
    • Data binding (How to bind parameters in a servlet to a business logic object)
    • Data validation (judging whether the data conforms to business rules, such as whether the message is formatted correctly)
    • Visual analysis (which view template is used for rendering)
    • Model passing and view rendering (passing data to a template and referencing it in a template)
    • ...
with spring MVC, you can simply write a simple Pojo code (, implement a controller with Pojo), or implement the interface that spring MVC provides to you (such as implementing interceptor as a permission judge) to accomplish these tedious functions.
Pojo is an abbreviation for plain old Java object, a concept proposed by the software development guru Martin Fowler, referring to a common Java class. Also say that you write a Java class casually, you can call it Pojo. The reason for such a special term is to be differentiated from code based on the heavyweight development framework, such as EJB, where we write classes that generally require compliance with specific coding specifications, implement specific interfaces, inherit specific base classes, and Pojo can be said to be Baiwujinji, flexible and convenient.

And the ORM is very intuitive, without repeating, it provides a layer of intermediate abstraction with database operations, so that the model code will be more simple. Spring MVC basically can help you block the servlet's Api,orm can help you block the JDBC API, that is, you write the program at a higher level of abstraction, the higher level of abstraction generally means to think more in line with our thinking, natural efficiency is higher. This is in fact one of the most important drivers of software technology development. You think, from the Assembly language development of high-level language, from the file system to develop a database, in fact, the essence of the law is similar.

Each of the small squares in the diagram is actually a large number of Java classes, between the controller and model, the model and the data access objects between these arrows, meaning there are a lot of complex dependencies between these Java classes. Spring's core functionality relies on injection, which is used to manage dependencies between Java objects, so the first part we say Spring is a one-stop glue frame that, like magic glue, can be organically bonded together in a loosely coupled way.

On MVC, Spring MVC,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.