CN110995799B - Data interaction method based on Fetch and springMVC - Google Patents
Data interaction method based on Fetch and springMVC Download PDFInfo
- Publication number
- CN110995799B CN110995799B CN201911152601.3A CN201911152601A CN110995799B CN 110995799 B CN110995799 B CN 110995799B CN 201911152601 A CN201911152601 A CN 201911152601A CN 110995799 B CN110995799 B CN 110995799B
- Authority
- CN
- China
- Prior art keywords
- request
- fetch
- wrapper
- data
- java
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/565—Conversion or adaptation of application format or content
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
A data interaction method based on Fetch and springMVC can solve the problem that a server end cannot acquire parameters in a comment mode in data interaction of the Fetch and the springMVC, parameters after check and type conversion can be acquired by a parameter binding comment module of a springMVC framework when the Fetch and the springMVC perform data interaction, seamless butt joint of the server end and a client end is achieved, development complexity and difficulty can be greatly reduced by achieving seamless butt joint of the data interaction, the advantage of the Fetch technology is added with the data interaction mode, the purpose of saving network resources is achieved, and network interaction is enabled to be rapid and stable.
Description
Technical Field
The invention relates to the technical field of HTTP data requests, in particular to a data interaction method based on Fetch and springMVC.
Background
The WEB front-end language ES6 has added an HTTP data request, namely Fetch, which has many similar functions to AJAX, but is designed to be more extensible and efficient than AJAX. Therefore, in more and more WEB application development, Fetch starts to be widely used, and traditional AJAX is gradually replaced by Fetch. However, the problem with this is that when the server side uses the framework of J2EE and springMVC, because the data requests are in different ways, and are also transmitted json-type data, AJAX can seamlessly interact with springMVC, and the comment @ RequestParam is used at the Controller layer of springMVC to obtain parameters after checksum data type conversion, whereas Fetch obtains null when obtaining parameters with the comment @ RequestParam, and even cannot obtain parameter values with the getParameter ("parameter name") method of http server.
Disclosure of Invention
In order to overcome the defects of the technology, the invention provides a data interaction method based on Fetch and springMVC, which reduces the development complexity and difficulty.
The technical scheme adopted by the invention for overcoming the technical problems is as follows:
a data interaction method based on Fetch and springMVC comprises the following steps:
s11) the browser of the client side makes a data request to the server side in a Fetch mode;
s12) the server analyzes the requested data through a Filter module in Java;
s13) the server side replaces the current request in the Java by the entity class of the request wrapper through a Filter module in the Java to obtain the replaced request wrapper;
s14) the server side takes the replaced request wrapper through a springMCV module in Java, and a Controller layer in the springMCV module obtains parameters after checksum data type conversion through an annotation mode;
s15) the server side processes the request sent by the client side and returns data to the Fetch;
s16) the client acquires the data returned by the server through the Fetch.
Preferably, the request parameter part of the data request in step S11) takes the form of a json string.
Further, the process of replacing the current request in Java by the entity class of the request wrapper through the Filter module in Java by the server side in step S13) includes the following steps:
s13-1) the server side acquires the requested data stream in the request wrapper and converts the requested data stream into a json character string;
s13-2) converting the json character string into a json object through a general data analysis module in Java;
s13-3) store the key-value pair in json in the private Map container of the request wrapper, overwrite getParameterMap () method in the request wrapper, overwrite getParameterNames () method in the request wrapper, overwrite getParameterValues () in the request wrapper, and overwrite getparametervalue () in the request wrapper and getparameterer (stir name) in the request wrapper.
The invention has the beneficial effects that: the problem that the server end cannot acquire parameters and check and type conversion of the parameters in an annotation mode in data interaction of Fetch and spring MVC can be solved through a data interaction mode, the parameters after the check and type conversion can be acquired by using a parameter binding annotation module of a spring MVC framework when the Fetch and the spring MVC perform data interaction, seamless butt joint of the server end and the client end data interaction is achieved, the development complexity and difficulty can be greatly reduced through the seamless butt joint of the data interaction, the aim of saving network resources is achieved by adding the advantages of the Fetch technology to the data interaction mode, and network interaction is enabled to be fast and stable.
Drawings
FIG. 1 is a schematic flow chart of the present invention.
Detailed Description
The invention is further described below with reference to fig. 1.
A data interaction method based on Fetch and springMVC comprises the following steps:
s11) the browser of the client side makes a data request to the server side in a Fetch mode;
s12) the server analyzes the requested data through a Filter module in Java;
s13) the server side replaces the current request in the Java by the entity class of the request wrapper through a Filter module in the Java to obtain the replaced request wrapper. The entity class of the request wrapper is the entity class of the http server.
S14) the server side takes the replaced request wrapper through a springMCV module in Java, and a Controller layer in the springMCV module obtains parameters after checksum data type conversion through an annotation mode;
s15) the server side processes the request sent by the client side and returns data to the Fetch;
s16) the client acquires the data returned by the server through the Fetch.
The problem that the server end cannot acquire parameters and check and type conversion of the parameters in an annotation mode in data interaction of Fetch and spring MVC can be solved through a data interaction mode, the parameters after the check and type conversion can be acquired by using a parameter binding annotation module of a spring MVC framework when the Fetch and the spring MVC perform data interaction, seamless butt joint of the server end and the client end data interaction is achieved, the development complexity and difficulty can be greatly reduced through the seamless butt joint of the data interaction, the aim of saving network resources is achieved by adding the advantages of the Fetch technology to the data interaction mode, and network interaction is enabled to be fast and stable.
Preferably, the request parameter part of the data request in step S11) takes the form of a json string.
Specifically, the process of replacing the current request in Java by the entity class of the request wrapper through the Filter module in Java by the server side in step S13) includes the following steps:
s13-1) the server side acquires the requested data stream in the request wrapper and converts the requested data stream into json character strings.
S13-2) converting the json character string into a json object through a general data analysis module in Java.
S13-3) store the key-value pair in json in the private Map container of the request wrapper, overwrite getParameterMap () method in the request wrapper, overwrite getParameterNames () method in the request wrapper, overwrite getParameterValues () in the request wrapper, and overwrite getparametervalue () in the request wrapper and getparameterer (stir name) in the request wrapper. The purpose of the rewrite getParameterMap () method is to return a Map container storing key-value pairs, the purpose of the rewrite getParameterNames () method is to return an execution of a key storing a key-value pair Map container, the purpose of the rewrite getParameterValues () is to return an array of values for a key-value pair Map container, and the purpose of the rewrite getparametername (stirnname) is to return the corresponding values in a Map according to the key. Prepare for the parameter binding annotation module for springMVC by 4 rewrites.
Claims (2)
1. A data interaction method based on Fetch and springMVC is characterized by comprising the following steps:
s11) the browser of the client side makes a data request to the server side in a Fetch mode;
s12) the server analyzes the requested data through a Filter module in Java;
s13) the server side replaces the current request in the Java by the entity class of the request wrapper through a Filter module in the Java to obtain the replaced request wrapper;
s14) the server side takes the replaced request wrapper through a springMCV module in Java, and a Controller layer in the springMCV module obtains parameters after checksum data type conversion through an annotation mode;
s15) the server side processes the request sent by the client side and returns data to the Fetch;
s16) the client side obtains data returned by the server side through the Fetch;
step S13), the process that the server side replaces the current request in the Java by the entity class of the request wrapper through the Filter module in the Java includes the following steps:
s13-1) the server side acquires the requested data stream in the request wrapper and converts the requested data stream into a json character string;
s13-2) converting the json character string into a json object through a general data analysis module in Java;
s13-3) store the key-value pair in json in the private Map container of the request wrapper, overwrite getParameterMap () method in the request wrapper, overwrite getParameterNames () method in the request wrapper, overwrite getParameterValues () in the request wrapper, and overwrite getparametervalue () in the request wrapper and getparameterer (stir name) in the request wrapper.
2. The method for data interaction between Fetch and springMVC according to claim 1, wherein: the request parameter portion of the data request in step S11) takes the form of a json string.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911152601.3A CN110995799B (en) | 2019-11-22 | 2019-11-22 | Data interaction method based on Fetch and springMVC |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911152601.3A CN110995799B (en) | 2019-11-22 | 2019-11-22 | Data interaction method based on Fetch and springMVC |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110995799A CN110995799A (en) | 2020-04-10 |
CN110995799B true CN110995799B (en) | 2022-03-18 |
Family
ID=70085753
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911152601.3A Active CN110995799B (en) | 2019-11-22 | 2019-11-22 | Data interaction method based on Fetch and springMVC |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110995799B (en) |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080201118A1 (en) * | 2007-02-16 | 2008-08-21 | Fan Luo | Modeling a web page on top of HTML elements level by encapsulating the details of HTML elements in a component, building a web page, a website and website syndication on browser-based user interface |
US20130262242A1 (en) * | 2012-03-28 | 2013-10-03 | Etalia SA | Method and Apparatus for the Handling and Aggregation of Multimedia Contents, for the Creation and Distribution of Multimedia Aggregates and the Distribution of the Associated Advertising Revenue |
CN104679898A (en) * | 2015-03-18 | 2015-06-03 | 成都汇智远景科技有限公司 | Big data access method |
US10289494B1 (en) * | 2017-04-27 | 2019-05-14 | EMC IP Holding Company LLC | Smart connector for network data management protocol (NDMP) backups |
-
2019
- 2019-11-22 CN CN201911152601.3A patent/CN110995799B/en active Active
Non-Patent Citations (2)
Title |
---|
vue+fetch+springMVC实现数据交互;queena不一样的烟火;《CSDN https://blog.csdn.net/liuminyi1987/article/details/81507317》;20180808;正文 * |
基于Spring+SpringMVC+hibernate框架的Web系统设计与实现;朱运乔;《电脑知识与技术》;20180915(第26期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110995799A (en) | 2020-04-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA2954294C (en) | Website access method, apparatus, and website system | |
CN111277643B (en) | Http link tracking recording method and system | |
CN101719902B (en) | Remote procedure calling (PRC) method and system | |
US20160162344A1 (en) | Generation of representational state transfer interface from application programming interfaces | |
US9594477B1 (en) | Using deep links to restore interactive state of a web page | |
CN104267944A (en) | Spring-based MVC (model view controller) mode optimization system | |
CN104615462B (en) | Cross-platform Mobile solution generation service end and system | |
US10073761B2 (en) | Legacy system | |
CN104461513B (en) | A kind of method and device for generating form interface | |
CN111881394B (en) | Request processing method and system for application middle layer | |
CN105763619A (en) | Method and device for communication of client and server | |
US20080208979A1 (en) | Dispatching client requests to appropriate server-side methods | |
CN113242221A (en) | Protocol conversion method and protocol conversion device based on http micro-service gateway | |
CN110995799B (en) | Data interaction method based on Fetch and springMVC | |
CN113923200A (en) | Method and device for realizing massive API gateway service | |
CN103927301B (en) | A kind of method and device of utilization theme bag dynamic translation entry | |
CN107239265B (en) | Binding method and device of Java function and C function | |
CN105528424B (en) | The system and method for data persistence is realized under big data environment | |
CN108228365A (en) | A kind of function request sending method, function request call method and device | |
CN111338685B (en) | Common component configuration method, device, equipment and storage medium | |
CN106293862A (en) | A kind of analysis method and device of expandable mark language XML data | |
CN109543127A (en) | A kind of page furbishing method, device, equipment and readable storage medium storing program for executing | |
CN101610284B (en) | Service parameter relational matching method and system based on calling data | |
CN115248887A (en) | Crawler method based on streaming download | |
CN106598663A (en) | Web application update method and web server |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: A Data Exchange Method Based on Fetch and SpringMVC Effective date of registration: 20230725 Granted publication date: 20220318 Pledgee: Ji'nan finance Company limited by guarantee Pledgor: SHANDONG JIUZHOU XINTAI INFORMATION TECHNOLOGY CO.,LTD. Registration number: Y2023980049639 |
|
PE01 | Entry into force of the registration of the contract for pledge of patent right |