CN111240668A - Method for constructing user interface framework based on Spring MVC - Google Patents
Method for constructing user interface framework based on Spring MVC Download PDFInfo
- Publication number
- CN111240668A CN111240668A CN201811434675.1A CN201811434675A CN111240668A CN 111240668 A CN111240668 A CN 111240668A CN 201811434675 A CN201811434675 A CN 201811434675A CN 111240668 A CN111240668 A CN 111240668A
- Authority
- CN
- China
- Prior art keywords
- controller
- model
- view
- request
- dispatcterservlet
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a method for constructing a user interface framework based on Spring MVC, and with the popularization of Web application, a series of universal development modes are gradually formed by Web development technology, so that Web application developers greatly reduce repetitive workload and improve the development efficiency of application. Among these modes, the MVC mode based on the Model, View, and Controller hierarchical structure has the advantages of low coupling, high portability, layer-by-layer separation, and the like, and is gradually becoming the mainstream mode of Web application development. However, the MVC mode has its disadvantages, mainly two-fold: firstly, the test unit excessively depends on ServeltAPI, so that the difficulty of unit test is greatly increased; second, the Controller caching process in MVC requires invoking a caching mechanism of Servlet, which lacks flexibility. The optimization scheme is mainly provided for the two defects.
Description
Technical Field
The invention relates to the technical field of computer application, in particular to a method for constructing a user interface framework based on Spring MVC. The rapid development of the internet has a great influence on human life, and brings a change of covering the land to the society, no matter the country, government, enterprise or individual. People's favor for information technology, which promotes the rapid development of information technology, computer technology and network technology, and new theory, new technology, new concept and new idea are developed endlessly, but with the continuous increase of people's demand, the complexity of the development process of software products is higher and higher. In order to solve these problems, people continue to think and search and then propose solutions corresponding to the problems, such as the generation of design mode concepts.
Background
In recent years, with the spread of the internet, a Web application method developed based on the B/S model has been rapidly developed due to advantages such as its general use, easy use, thin client, etc., and has become a mainstream technology for applications such as an electronic commerce method and an office method, and advantages thereof are more significant in methods such as a portal site of a government or an enterprise, a B2B electronic commerce site, etc.
With the popularization of Web application, a series of general development modes are gradually formed by Web development technology, so that the repetitive workload of Web application developers is greatly reduced, and the development efficiency of the application is improved. Among these modes, the MVC mode based on the Model, View, and Controller hierarchical structure has the advantages of low coupling, high portability, layer-by-layer separation, and the like, and is gradually becoming the mainstream mode of Web application development. However, the MVC mode has its disadvantages, mainly two-fold: firstly, the test unit is excessively dependent on Servlet API, so that the difficulty of unit test is greatly increased; second, the Controller caching process in MVC requires invoking a caching mechanism of Servlet, which lacks flexibility. The optimization scheme is mainly provided for the two defects.
For Web application developers, it is a pursued goal to shorten the development period, reduce the development cost, improve the operation efficiency, and enhance the maintainability. The appearance and wide application of the J2EE platform reduce the cost of Web application development to some extent and also reduce the complexity of the development process, but due to the defects of excessively complex architecture, difficulty in accurately predicting the process and result of the application, high price of the development and maintenance cost process and the like, the architecture scheme of the J2EE cannot be really satisfied. Many Web application frameworks have evolved in response to the various drawbacks and deficiencies noted above.
Struts framework: the Struts is a Lao brand Web application framework and also is the most widely applied framework in cash application, and is mainly realized by adopting Servlet and JSP technologies, and comprises a front-end control component, a series of action classes, action mapping, XML processing using tool classes, server-end JavaBean automatic filling, verification supporting Web forms, international support, HTML generation and other functions and contents. The main drawback of Struts is the lack of perfect authority setting and the lack of support of the data layer, so its use must be completely dependent on the specific framework class. Moreover, in practical applications, Struts cannot use the domain object as a FormBean, which generates many additional formbeans, resulting in unnecessary repeatability. Meanwhile, the view part of the method is limited to support JSP technology, and a complete support scheme is not provided for other view technologies.
EJB technique: this technology, which arose in month 3 of 1998 and which had been the core of J2EE, was primarily aimed at simplifying enterprise-level application development so that developers can devote more effort on business logic rather than on methodological issues.
Spring frame: in 2002, Rod Johnson summarizes some defects of the current framework technology, a book of 'Expert One-on-One J2EE Design and Development' is published, some experiences of the project Development are summarized, the reasons of project failure caused by the EJB technology are analyzed, and the content in the book later becomes the core idea of the Spring framework.
By combining the working principle and the characteristics of Spring MVC, aiming at the defects that the Spring MVC excessively depends on Servlet API and is not beneficial to unit test, the service logic processing class and the interface are packaged, so that the Servlet is decoupled.
Disclosure of Invention
The invention aims to provide a method for constructing a user interface framework based on Spring MVC.
The object of the invention is achieved in the following way, comprising:
1) the core class and interface of Spring MVC framework:
① Dispatcterservlet realizes the design mode of the front-end controller, provides the node of centralized access;
② HandlerMapping interface maps the request to the processor, and returns a processor execution chain including a processor and a plurality of interceptors;
③ SimpleUrlHandlerMapping and DefaultAnnotationHandlerMapping classes realize HandlerMapping interfaces, and the URLs are mapped to a controller class through configuration files and notes respectively;
④ ViewResolver resolves the logical view name to a specific attempted implementation;
⑤ HandlerExceptionResolver resolves exceptions encountered during execution;
⑥ Dispatcterservlet maps the request to the processor, including returning a HandlerExecutionChain, which includes a processor, a plurality of interceptors;
2) controller
The controller acquires a request of a client, converts the supply and demand of a parent pen into a data model, performs Web logic processing, and finally displays a processing result to a user through a proper view, wherein the controller comprises a core controller and a service controller, the core controller is responsible for receiving the request of the client, and the service controller is responsible for processing the logic service of the request;
3) model and view encapsulation module
The model and view packaging module is used for packaging a model and view processing program and is used for generating a model and a view displayed in a browser, the model and view object is analyzed into a model and a view after being processed by the DispatcterServlet, and then the model is loaded into the view and returned to a user;
the client request processing steps are as follows:
① initializing the Spring container according to the parameters in the configuration file;
② the user sends out a request, the Dispatcterservlet analyzes the request and submits it to the core controller for logic processing;
③ creating a model view object, packaging the request processing result to the object, and returning to Dispatcterservlet;
④ Dispatcterservlet parses the model view object and feeds back the result to the client.
The invention has the beneficial effects that: through the mode, the optimization process of the controller is that the controller and the ServeltAPI are completely decoupled, the cache functions in different level ranges are provided, and the purpose of expected optimization is achieved.
Detailed Description
Aiming at the defects that the method excessively depends on Servlet API and is not beneficial to unit test, the service logic processing class and the interface are packaged to realize the decoupling of Servlet.
The method comprises the following specific steps:
① creates controller interface OptimizingContext, declares the method of obtaining HttpServletRequest and HttpServletResponse.
The code of the interface is as follows:
public interface OptimizingContext{
public HttpServletRequest getServletRequest();
public HttpServletResponse getServletResponse();
}
creating an implementation class OptimizContextImpl of an OptimizingContext interface, wherein references of 4 Map objects are stored in the implementation class, the references are respectively used for storing page information (pageInfoMap), request data (requestMap), session data (sessionMap) and application data (applicationMap), and the implementation class provides assignment and value methods for the 4 objects.
public class OptimizingContextImpl implements OptimizingContext{
static ThreadLocal ptimizingContext = new ThreadLocal();
private HttpServletRequest request;
public OptimizingContextImpl(Map<String ,Object>context){
this.context = context;
}
public HttpServletRequest getServletRequest(){
return request;
}
public void setServletRequest(){
this.request = request;
}
}
② extended controller class
The controller class in the Spring MVC framework implements the controller interface under the Spring framework, which provides a method for processing user requests and returning corresponding model views. The controller defined by Spring is realized by inheriting an extended controller class instead of directly realizing a controller interface;
③ controller optimization
A controller for optimizing a Spring MVC framework firstly needs to design a controller class of the controller, namely inheriting an extension controller class, and rewrites a handleRequstInternal method of the class, and the method mainly comprises the following steps: creating an abstract subclass of the extension pre-sale period, creating a Handle function in the subclass for processing the client request, wherein the concrete implementation of the Handle function is completed by the abstract subclass.
In addition to the technical features described in the specification, the technology is known to those skilled in the art.
Claims (1)
1. A method for constructing a user interface framework based on Spring MVC is characterized by comprising the following steps:
1) the core class and interface of Spring MVC framework:
① Dispatcterservlet realizes the design mode of the front-end controller, provides the node of centralized access;
② HandlerMapping interface maps the request to the processor, and returns a processor execution chain including a processor and a plurality of interceptors;
③ SimpleUrlHandlerMapping and DefaultAnnotationHandlerMapping classes realize HandlerMapping interfaces, and the URLs are mapped to a controller class through configuration files and notes respectively;
④ ViewResolver resolves the logical view name to a specific attempted implementation;
⑤ HandlerExceptionResolver resolves exceptions encountered during execution;
⑥ Dispatcterservlet maps the request to the processor, including returning a HandlerExecutionChain, which includes a processor, a plurality of interceptors;
2) controller
The controller acquires a request of a client, converts the supply and demand of a parent pen into a data model, performs Web logic processing, and finally displays a processing result to a user through a proper view, wherein the controller comprises a core controller and a service controller, the core controller is responsible for receiving the request of the client, and the service controller is responsible for processing the logic service of the request;
3) model and view encapsulation module
The model and view packaging module is used for packaging a model and view processing program and is used for generating a model and a view displayed in a browser, the model and view object is analyzed into a model and a view after being processed by the DispatcterServlet, and then the model is loaded into the view and returned to a user;
the client request processing steps are as follows
① initializing the Spring container according to the parameters in the configuration file;
② the user sends out a request, the Dispatcterservlet analyzes the request and submits it to the core controller for logic processing;
③ creating a model view object, packaging the request processing result to the object, and returning to Dispatcterservlet;
④ Dispatcterservlet parses the model view object and feeds back the result to the client.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811434675.1A CN111240668A (en) | 2018-11-28 | 2018-11-28 | Method for constructing user interface framework based on Spring MVC |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811434675.1A CN111240668A (en) | 2018-11-28 | 2018-11-28 | Method for constructing user interface framework based on Spring MVC |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111240668A true CN111240668A (en) | 2020-06-05 |
Family
ID=70879197
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811434675.1A Pending CN111240668A (en) | 2018-11-28 | 2018-11-28 | Method for constructing user interface framework based on Spring MVC |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111240668A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111931087A (en) * | 2020-09-15 | 2020-11-13 | 新华三半导体技术有限公司 | Webpage request processing method and device |
CN112506679A (en) * | 2020-12-17 | 2021-03-16 | 中国联合网络通信集团有限公司 | RPC service calling method and equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104267944A (en) * | 2014-09-22 | 2015-01-07 | 浪潮软件集团有限公司 | Spring-based MVC (model view controller) mode optimization system |
CN105867948A (en) * | 2016-04-26 | 2016-08-17 | 江苏物联网研究发展中心 | WEB development method based on AJAX (Asynchronous JavaScript and XML) and Spring MVC (model view controller) |
-
2018
- 2018-11-28 CN CN201811434675.1A patent/CN111240668A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104267944A (en) * | 2014-09-22 | 2015-01-07 | 浪潮软件集团有限公司 | Spring-based MVC (model view controller) mode optimization system |
CN105867948A (en) * | 2016-04-26 | 2016-08-17 | 江苏物联网研究发展中心 | WEB development method based on AJAX (Asynchronous JavaScript and XML) and Spring MVC (model view controller) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111931087A (en) * | 2020-09-15 | 2020-11-13 | 新华三半导体技术有限公司 | Webpage request processing method and device |
CN112506679A (en) * | 2020-12-17 | 2021-03-16 | 中国联合网络通信集团有限公司 | RPC service calling method and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104267944A (en) | Spring-based MVC (model view controller) mode optimization system | |
US7917524B2 (en) | Systems and methods for providing a mockup data generator | |
US7992127B2 (en) | Method and system of encapsulating web site transactions for computer-aided generation of web services | |
CN104391868A (en) | Staticizing device and method for dynamic page | |
RU2008108999A (en) | Kind of a Named Object of the Electronic Data Report | |
CN102567400B (en) | Method for realizing Web visit and Web server | |
US20080086505A1 (en) | Presenting user interfaces based on messages | |
CN103970534A (en) | Method and equipment for supplying rendered page in mobile application | |
CN105260420A (en) | Method and device for providing target page in mobile application | |
CN102325191A (en) | Fully automatic treatment method and frame without page refresh | |
TW201732626A (en) | Method and device for acquiring application resource | |
CN111240668A (en) | Method for constructing user interface framework based on Spring MVC | |
WO2014059182A1 (en) | Testing an executable binary file using an injection proxy | |
CN108874922A (en) | Client device, webpage rendering method and storage medium based on single page application | |
CN106570750A (en) | Browser plug-in-based automatic tax declaration method, system and browser plug-in | |
CN110825641B (en) | Micro-service application test system based on simulation data generator | |
CN102637194B (en) | Trigger method for late binding event of Web page element in BHO (browser helper object) | |
CN106777352A (en) | Data access method and system | |
CN111240666A (en) | System for constructing user interface framework based on Spring MVC | |
Liu et al. | Layered queueing models for enterprise JavaBean applications | |
US20150067089A1 (en) | Metadata driven declarative client-side session management and differential server side data submission | |
US20060020908A1 (en) | Unified Approach to Building Web Applications that can be deployed as stand-alone and in Web Portals | |
Khan et al. | XWADF: Architectural pattern for improving performance of web applications | |
CN111881043A (en) | Page testing method and device, storage medium and processor | |
CN111046062A (en) | Applet data acquisition method, intelligent terminal and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20200605 |
|
WD01 | Invention patent application deemed withdrawn after publication |