Write an overview of Framework-MVC Framework (i)

Source: Internet
Author: User

Basic MVC sub-framework Overview

Let's call this MVC framework a BASICMVC framework for the time being.

Since we are BASICMVC the framework, it is implemented based on the BASICIOC kernel we wrote earlier. So you have to rely on the BASICIOC kernel. What we call the BASICMVC framework is the sub-framework of the BASICIOC framework.

in Basicmvc before the framework is implemented, we must first understand MVC the meaning.

Definition of MVC

MVC full name:model-view-cotroller. is: Model - View - Controller.

can literally be seen as a the process of a WEB request to a call to the background logic code. This means that when accessing the background logic code from the page, follow the process of (model - view - controller - Logic processing code).

to put it bluntly, it is suggested that we do not write the background logic code in the view, the view only write the view of the label, all the logic code to the background processing, the view and the background code jump and the Data encapsulation (form data to entity Class) are done at the controller.

so say: MVC is a design idea that realizes the separation of view code and background logic code in WEB programming.

MVC Design Ideas Flowchart (general)

so according to The MVC Design idea is thattheMVC Framework process is:

1. a program requesting access to the Javaweb must enter the entry to the javaweb program , Web. XML

2. We Configure a core controller in Web. XML to intercept all requests

3. The core controller thenfinds the method to be executed, based on the configuration of the request and execution method (which can be used with annotations or XML)

4. the execution method executes a map that returns a view (can be implemented through a string or a custom class)

5. jump back to the view based on the relationship between the view map and the view path.

As shown in the following:

after such an analysis, it was found that any MVC Framework, the implementation of the process is very similar. Found no, hahaha, haha ha ha!

1.3. Framework Implementation Flowchart

based on the above process, I based my own logic on the framework basic MVC Sub-framework to make the following designs.

the idea of implementing MVC request Jump

Define a core controller, named Dispacherservlet, the core controller first realizes:

(1) When starting the Javaweb project, load all program objects into the container pool using the Ioc kernel mechanism.

we must be in Web Launch is to create a applicationcontext container operation object;

We must need a configuration class to get the information to create the container

(2) in the request to invoke the execution method, then we need to specify the request path and method relationship.

I define a @RequestMaping annotation To specify their relationship

(3) after the method executes, returns the view map, which I use as a string corresponding to the view path.

achieve the above three steps. A basic MVC Framework is complete. We need the code to implement it together!

Write an overview of Framework-MVC Framework (i)

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.