CN104267944A - Spring-based MVC (model view controller) mode optimization system - Google Patents
Spring-based MVC (model view controller) mode optimization system Download PDFInfo
- Publication number
- CN104267944A CN104267944A CN201410485482.4A CN201410485482A CN104267944A CN 104267944 A CN104267944 A CN 104267944A CN 201410485482 A CN201410485482 A CN 201410485482A CN 104267944 A CN104267944 A CN 104267944A
- Authority
- CN
- China
- Prior art keywords
- model
- controller
- view
- request
- mvc
- 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
- 238000005457 optimization Methods 0.000 title claims abstract description 8
- 238000000034 method Methods 0.000 claims abstract description 20
- 230000008569 process Effects 0.000 claims abstract description 11
- 238000012545 processing Methods 0.000 claims description 8
- 238000013461 design Methods 0.000 claims description 4
- 238000013499 data model Methods 0.000 claims description 2
- 238000011161 development Methods 0.000 abstract description 15
- 238000005516 engineering process Methods 0.000 abstract description 14
- 230000008901 benefit Effects 0.000 abstract description 5
- 238000012360 testing method Methods 0.000 abstract description 5
- 230000008878 coupling Effects 0.000 abstract description 3
- 238000010168 coupling process Methods 0.000 abstract description 3
- 238000005859 coupling reaction Methods 0.000 abstract description 3
- 230000007547 defect Effects 0.000 abstract description 2
- 230000007246 mechanism Effects 0.000 abstract description 2
- 230000003252 repetitive effect Effects 0.000 abstract description 2
- 238000000926 separation method Methods 0.000 abstract description 2
- 230000007812 deficiency Effects 0.000 description 3
- 230000009471 action Effects 0.000 description 2
- 238000005538 encapsulation Methods 0.000 description 2
- 235000006719 Cassia obtusifolia Nutrition 0.000 description 1
- 235000014552 Cassia tora Nutrition 0.000 description 1
- 244000201986 Cassia tora Species 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012913 prioritisation Methods 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Abstract
The invention provides a Spring-based MVC pattern optimization system, and with the popularization of Web application, a series of general development patterns 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 present invention relates to Computer Applied Technology field, specifically a kind of MVC model-based optimization system based on Spring.Developing rapidly of internet creates tremendous influence to human lives, brings earth-shaking change to society, and no matter being country, government, enterprise or individual, is all like this.People are to the favor of infotech, facilitate the develop rapidly of infotech, computer technology and network technology, new theory, new technology, new ideas, new idea emerge in an endless stream, but along with the continuous growth of people's demand, the complexity of the performance history of software product is also more and more higher.In the face of these problems, people are ceaselessly thinking deeply, groping and then are proposing corresponding solution again, such as the generation of Design Mode theory.
Background technology
In the past few years, along with popularizing of internet, based on the Web application system of B/S mode development, the advantages such as general by means of it, easy-to-use, thin-client achieve and develop rapidly, become the mainstream technology of the application such as e-commerce system, office system gradually, its advantage is more obvious in the system such as portal website, B2B E-commerce website of government or enterprise.
Along with popularizing of Web application, Web development technique also defines a series of general development mode gradually, makes Web application developer greatly reduce repetitive work amount, improves the development efficiency of application.In these patterns, the MVC pattern based on Model, View, Controller hierarchy has the advantages such as advantage such as low coupling, portable high, separation layer by layer and becomes the prevailing model of Web application and development gradually.But MVC pattern also has its weak point, mainly contains two aspects: the first, is too dependent on Servlet API, considerably increase the difficulty of unit testing; Controller caching process in the second, MVC needs the caching mechanism calling Servlet, lacks dirigibility.Prioritization scheme is provided herein mainly for above two kinds of deficiencies.
For Web application developer, shortening the construction cycle, reduce cost of development, improving operational efficiency and strengthen maintainability is the target that it is pursued.The appearance of J2EE platform and widespread use reduce the cost of Web application and development to a certain extent, also reduce the complexity of performance history, but due to the deficiency such as expensive of its self too complicated architecture, the process being difficult to Accurate Prediction application and result and development and maintenance cost process, often make the architectural schemes of J2EE cannot allow people's really satisfaction.For above-mentioned all drawbacks of mentioning and deficiency, many Web application frameworks arise at the historic moment.
Struts framework: Struts is the Web application framework of an old brand, also be use framework the most widely in cash application, it mainly adopts Servlet and JSP technology to realize, and comprises a front-end control assembly, a series of action class, action mapping, the use tool-class of processing XML, the automatic filling of server end JavaBean, the Web list supporting checking and the function and content such as International Support, generation HTML.The major defect of Struts lacks perfect authority setting, and do not have the support of data Layer, and therefore its use must place one's entire reliance upon concrete frame clsss.And in actual applications, domain object can not use as FormBean by Struts, can generate much extra FormBean like this, result in unnecessary repeatability.Meanwhile, its View component is only limitted to support JSP technology, and the view techniques for other does not provide perfect support scheme.
EJB technology: this technology results from March, 1998, then always as the core of J2EE, main object is to simplify enterprise-level application development, and more energy can be devoted on service logic instead of system level issues by developer.
Spring framework: 2002, Rod Johnson sums up the some shortcomings part of framework technology at that time, publish the book of " Expert One-on-One J2EE Design and Development ", summarize some experiences of his project development, analyze the reason etc. that EJB technology causes project failure, the content in this book became the core concept of Spring framework afterwards.
In conjunction with principle of work and the feature of Spring MVC, for the shortcoming that it is depended on Servlet API unduly and is unfavorable for unit testing, by encapsulation business logic processing class and interface, achieve the decoupling zero to Servlet.
Summary of the invention
The object of this invention is to provide a kind of MVC model-based optimization system based on Spring.
The object of the invention is to realize in the following manner, comprising:
1) core classes of Spring MVC framework and interface:
1. DispatcherServlet realizes the Design Mode of front controller, provides the node of central access;
2. request is mapped to processor by HandlerMapping interface, returns a processor and performs chain, comprise processor and multiple blocker;
3. SimpleUrlHandlerMapping, DefaultAnnotationHandlerMapping class realizes HandlerMapping interface, respectively by configuration file and note, is mapped to by URL on a controller class;
4. ViewResolver resolution logic view name is to specifically attempting to realize;
5. HandlerExceptionResolver resolves the exception run in implementation;
6. request is mapped to processor by DispatcherServlet, comprises and returns a HandlerExecutionChain, and it comprises a processor, multiple blocker;
2) controller
Controller obtains the request of client, and own handwriting supply and demand are changed into data model, carry out Web logical process, finally by suitable view, result is showed user, controller comprises core controller and service controller, core controller is responsible for receiving client's request, and service controller is responsible for the logic business processing request;
3) model and view package module
Model and view package module, encapsulate the handling procedure of model and view, for generation model and the view being illustrated in browser, model and view object are after DispatcherServlet process, be resolved as model and view two parts, then model be loaded in view and return to user;
Client's request processing step is as follows
1. Spring container carries out initialization according to the parameter in configuration file;
2. user sends request, and DispatcherServlet carries out logical process by submitting to core controller after request analysis;
3. model of creation view object, and request result is encapsulated into this object, return to DispatcherServlet;
4. DispatcherServlet analytic model view object, by result feedback to client.
Object beneficial effect of the present invention is: by the way, and the optimizing process of controller is that controller and Servlet API remove coupling completely, and provides the caching function of different stage scope, reaches the object that expection is optimized.
Embodiment
For the shortcoming that it is depended on Servlet API unduly and is unfavorable for unit testing, by encapsulation business logic processing class and interface, achieve the decoupling zero to Servlet.
Concrete steps are as follows:
1. create control unit interface OptimizingContext, statement obtains the method for HttpServletRequest and HttpServletResponse.The realizing class and can realize different functions according to different demands of this interface.Thus make subclass need not depend on the realization of parent.In Java, subclass can realize multiple interface, thus has greatly enriched the method for subclass object.
The code of this interface is as follows:
public interface OptimizingContext{
public HttpServletRequest getServletRequest();
public HttpServletResponse getServletResponse();
}
What create OptimizingContext interface realizes class OptimizingContextImpl, quoting of 4 Map objects is preserved in this type of, be respectively used to preserve page info (pageInfoMap), request msg (requestMap), session data (sessionMap), application data (applicationMap), realizing class is that 4 objects provide assignment and obtaining value method.
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;
}
}
2. extending controller class
Controller class in Spring MVC framework achieves the control unit interface under spring framework, it provides a method and is used for processing user's request, and return corresponding model view.The controller of Spring definition is not directly realize control unit interface, but inherits extending controller class and realize;
3. controller optimization
Optimize the controller of Spring MVC framework, first the controller class designing oneself is needed, namely extending controller class is inherited, rewrite such handleRequstInternal method, key step is: the abstract classes creating the extension name presell phase, in subclass, create handle function, for the treatment of client's request, the specific implementation of Handle function is completed by abstract classes.
Except the technical characteristic described in instructions, be the known technology of those skilled in the art.
Claims (1)
1., based on a MVC model-based optimization system of Spring, it is characterized in that comprising:
1) core classes of Spring MVC framework and interface:
1. DispatcherServlet realizes the Design Mode of front controller, provides the node of central access;
2. request is mapped to processor by HandlerMapping interface, returns a processor and performs chain, comprise processor and multiple blocker;
3. SimpleUrlHandlerMapping, DefaultAnnotationHandlerMapping class realizes HandlerMapping interface, respectively by configuration file and note, is mapped to by URL on a controller class;
4. ViewResolver resolution logic view name is to specifically attempting to realize;
5. HandlerExceptionResolver resolves the exception run in implementation;
6. request is mapped to processor by DispatcherServlet, comprises and returns a HandlerExecutionChain, and it comprises a processor, multiple blocker;
2) controller
Controller obtains the request of client, and own handwriting supply and demand are changed into data model, carry out Web logical process, finally by suitable view, result is showed user, controller comprises core controller and service controller, core controller is responsible for receiving client's request, and service controller is responsible for the logic business processing request;
3) model and view package module
Model and view package module, encapsulate the handling procedure of model and view, for generation model and the view being illustrated in browser, model and view object are after DispatcherServlet process, be resolved as model and view two parts, then model be loaded in view and return to user;
Client's request processing step is as follows
1. Spring container carries out initialization according to the parameter in configuration file;
2. user sends request, and DispatcherServlet carries out logical process by submitting to core controller after request analysis;
3. model of creation view object, and request result is encapsulated into this object, return to DispatcherServlet;
4. DispatcherServlet analytic model view object, by result feedback to client.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410485482.4A CN104267944A (en) | 2014-09-22 | 2014-09-22 | Spring-based MVC (model view controller) mode optimization system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410485482.4A CN104267944A (en) | 2014-09-22 | 2014-09-22 | Spring-based MVC (model view controller) mode optimization system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104267944A true CN104267944A (en) | 2015-01-07 |
Family
ID=52159468
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410485482.4A Pending CN104267944A (en) | 2014-09-22 | 2014-09-22 | Spring-based MVC (model view controller) mode optimization system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104267944A (en) |
Cited By (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105045573A (en) * | 2015-06-24 | 2015-11-11 | 国电南京自动化股份有限公司 | Photovoltaic power plant monitoring and commissioning software building method based on WEB screen-crossing technology |
CN105117938A (en) * | 2015-08-19 | 2015-12-02 | 江苏农牧人电子商务股份有限公司 | E-commerce framework request data analysis method based on model view controller |
CN105549972A (en) * | 2015-12-10 | 2016-05-04 | 天津海量信息技术有限公司 | Unified authentication protocol-based mvc frame structure and running method thereof |
CN105677326A (en) * | 2015-12-28 | 2016-06-15 | 国云科技股份有限公司 | Software interface parameter validation method |
CN105867948A (en) * | 2016-04-26 | 2016-08-17 | 江苏物联网研究发展中心 | WEB development method based on AJAX (Asynchronous JavaScript and XML) and Spring MVC (model view controller) |
CN105975265A (en) * | 2016-04-29 | 2016-09-28 | 掌赢信息科技(上海)有限公司 | Device based on improved MVP mode |
CN106528215A (en) * | 2016-10-25 | 2017-03-22 | 广东亿迅科技有限公司 | Java-based dynamic command loading method and device |
CN108089904A (en) * | 2017-12-21 | 2018-05-29 | 上海新案数字科技有限公司 | A kind of displayed page extended method and equipment |
CN108647107A (en) * | 2018-05-14 | 2018-10-12 | 浪潮软件集团有限公司 | Unified exception handling method for micro-service development framework |
CN108881373A (en) * | 2018-04-27 | 2018-11-23 | 安徽四创电子股份有限公司 | A kind of front end data method for stream processing based on MVC frame |
CN109543131A (en) * | 2018-11-15 | 2019-03-29 | 国电南瑞科技股份有限公司 | A kind of realization system and method for the distribution terminal model maintenance tool based on B/S framework |
CN110069297A (en) * | 2019-03-28 | 2019-07-30 | 平安科技(深圳)有限公司 | Abnormality eliminating method, device, computer equipment and storage medium based on Spring MVC |
US10389837B2 (en) | 2016-06-17 | 2019-08-20 | International Business Machines Corporation | Multi-tier dynamic data caching |
CN110609680A (en) * | 2019-09-19 | 2019-12-24 | 北京锐安科技有限公司 | Parameter transmission method and device based on Spring interceptor, storage medium and equipment |
CN111176632A (en) * | 2020-01-02 | 2020-05-19 | 山东浪潮通软信息科技有限公司 | Method for building iOS end response type development framework |
CN111240668A (en) * | 2018-11-28 | 2020-06-05 | 常熟昊虞电子信息科技有限公司 | Method for constructing user interface framework based on Spring MVC |
CN111240666A (en) * | 2018-11-28 | 2020-06-05 | 常熟昊虞电子信息科技有限公司 | System for constructing user interface framework based on Spring MVC |
CN115169848A (en) * | 2022-06-28 | 2022-10-11 | 上海东普信息科技有限公司 | Statistical analysis method, device, equipment and storage medium for logistics business data |
CN115481355A (en) * | 2022-09-19 | 2022-12-16 | 北京三维天地科技股份有限公司 | Data modeling method based on category expansion |
US11531733B2 (en) | 2019-03-18 | 2022-12-20 | Fuzhou Boe Optoelectronics Technology Co., Ltd. | Authority filter method and authority filter device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030233631A1 (en) * | 2002-06-13 | 2003-12-18 | Ambrose Curry | Web services development method |
CN101901163A (en) * | 2010-07-13 | 2010-12-01 | 北京世纪高通科技有限公司 | Method and device for distributing messages |
CN103677788A (en) * | 2012-09-25 | 2014-03-26 | 深圳市金正方科技股份有限公司 | Reuse framework generating method, device and application system based on J2EE distributed architecture |
-
2014
- 2014-09-22 CN CN201410485482.4A patent/CN104267944A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030233631A1 (en) * | 2002-06-13 | 2003-12-18 | Ambrose Curry | Web services development method |
CN101901163A (en) * | 2010-07-13 | 2010-12-01 | 北京世纪高通科技有限公司 | Method and device for distributing messages |
CN103677788A (en) * | 2012-09-25 | 2014-03-26 | 深圳市金正方科技股份有限公司 | Reuse framework generating method, device and application system based on J2EE distributed architecture |
Non-Patent Citations (2)
Title |
---|
廖福保: ""扩展Spring MVC模块的Web应用"", 《实验室研究与探索》 * |
徐雯等: ""基于Spring MVC及MyBatis的Web应用框架研究"", 《研究与设计》 * |
Cited By (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105045573B (en) * | 2015-06-24 | 2018-03-23 | 国电南京自动化股份有限公司 | Based on WEB across the photovoltaic plant monitoring of screen technology and debugging software method for building up |
CN105045573A (en) * | 2015-06-24 | 2015-11-11 | 国电南京自动化股份有限公司 | Photovoltaic power plant monitoring and commissioning software building method based on WEB screen-crossing technology |
CN105117938A (en) * | 2015-08-19 | 2015-12-02 | 江苏农牧人电子商务股份有限公司 | E-commerce framework request data analysis method based on model view controller |
CN105549972A (en) * | 2015-12-10 | 2016-05-04 | 天津海量信息技术有限公司 | Unified authentication protocol-based mvc frame structure and running method thereof |
CN105677326A (en) * | 2015-12-28 | 2016-06-15 | 国云科技股份有限公司 | Software interface parameter validation method |
CN105677326B (en) * | 2015-12-28 | 2019-03-22 | 国云科技股份有限公司 | A kind of software interface Verification method |
CN105867948A (en) * | 2016-04-26 | 2016-08-17 | 江苏物联网研究发展中心 | WEB development method based on AJAX (Asynchronous JavaScript and XML) and Spring MVC (model view controller) |
CN105975265A (en) * | 2016-04-29 | 2016-09-28 | 掌赢信息科技(上海)有限公司 | Device based on improved MVP mode |
CN105975265B (en) * | 2016-04-29 | 2019-04-12 | 掌赢信息科技(上海)有限公司 | A kind of device based on modified MVP mode |
US10389837B2 (en) | 2016-06-17 | 2019-08-20 | International Business Machines Corporation | Multi-tier dynamic data caching |
CN106528215A (en) * | 2016-10-25 | 2017-03-22 | 广东亿迅科技有限公司 | Java-based dynamic command loading method and device |
CN108089904A (en) * | 2017-12-21 | 2018-05-29 | 上海新案数字科技有限公司 | A kind of displayed page extended method and equipment |
CN108089904B (en) * | 2017-12-21 | 2021-11-16 | 上海七十迈数字科技有限公司 | Display page expansion method and device |
CN108881373A (en) * | 2018-04-27 | 2018-11-23 | 安徽四创电子股份有限公司 | A kind of front end data method for stream processing based on MVC frame |
CN108881373B (en) * | 2018-04-27 | 2021-07-06 | 安徽四创电子股份有限公司 | MVC (model view controller) framework based front-end data stream processing method |
CN108647107A (en) * | 2018-05-14 | 2018-10-12 | 浪潮软件集团有限公司 | Unified exception handling method for micro-service development framework |
CN109543131A (en) * | 2018-11-15 | 2019-03-29 | 国电南瑞科技股份有限公司 | A kind of realization system and method for the distribution terminal model maintenance tool based on B/S framework |
CN111240668A (en) * | 2018-11-28 | 2020-06-05 | 常熟昊虞电子信息科技有限公司 | Method for constructing user interface framework based on Spring MVC |
CN111240666A (en) * | 2018-11-28 | 2020-06-05 | 常熟昊虞电子信息科技有限公司 | System for constructing user interface framework based on Spring MVC |
US11531733B2 (en) | 2019-03-18 | 2022-12-20 | Fuzhou Boe Optoelectronics Technology Co., Ltd. | Authority filter method and authority filter device |
CN110069297A (en) * | 2019-03-28 | 2019-07-30 | 平安科技(深圳)有限公司 | Abnormality eliminating method, device, computer equipment and storage medium based on Spring MVC |
CN110609680A (en) * | 2019-09-19 | 2019-12-24 | 北京锐安科技有限公司 | Parameter transmission method and device based on Spring interceptor, storage medium and equipment |
CN111176632A (en) * | 2020-01-02 | 2020-05-19 | 山东浪潮通软信息科技有限公司 | Method for building iOS end response type development framework |
CN115169848A (en) * | 2022-06-28 | 2022-10-11 | 上海东普信息科技有限公司 | Statistical analysis method, device, equipment and storage medium for logistics business data |
CN115481355A (en) * | 2022-09-19 | 2022-12-16 | 北京三维天地科技股份有限公司 | Data modeling method based on category expansion |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104267944A (en) | Spring-based MVC (model view controller) mode optimization system | |
US20150160928A1 (en) | Business object model layer interface | |
CN101408899B (en) | Method and apparatus for switching website multiple data sources | |
Shan et al. | Taxonomy of java web application frameworks | |
US8504913B2 (en) | Client-side components | |
US20090217263A1 (en) | Virtual appliance factory | |
US8402319B2 (en) | Method and system to extract a navigation model for analysis of a web application | |
US20130339931A1 (en) | Application trace replay and simulation systems and methods | |
Arthur et al. | Spring Framework for rapid open source J2EE Web Application Development: A case study | |
US20120174068A1 (en) | Testing Software Code | |
CN102566984B (en) | Method and device for configuring parameters | |
CN105049435A (en) | Cloud testing framework oriented to protocol conformance of heterogeneous wireless sensor network | |
CN109871241A (en) | A kind of configuration method of Cross-environment application server | |
CN104572099A (en) | Assembly and middleware based low-coupling frame data processing method and system | |
Varanasi et al. | Spring Rest | |
Miravet et al. | Framework for the declarative implementation of native mobile applications | |
Jammal et al. | Generic input template for cloud simulators: A case study of CloudSim | |
CN111240668A (en) | Method for constructing user interface framework based on Spring MVC | |
Pinandito et al. | Framework design for modular web-based application using model-collectionservice-controller-presenter (mccp) pattern | |
CN105242913A (en) | YYUC-PHP (Professional Hypertext Preprocessor) frame | |
Song et al. | Implementation on network teaching system based on Java EE architecture | |
Khan et al. | XWADF: Architectural pattern for improving performance of web applications | |
US9195704B2 (en) | Automated logging for object-oriented environments | |
Wu et al. | Virtual watershed system: a web-service-based software package for environmental modeling | |
Mancini et al. | Performance-driven development of a web services application using MetaPL/HeSSE |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150107 |
|
WD01 | Invention patent application deemed withdrawn after publication |