CN110727537B - Method, device, computer equipment and storage medium for uniformly processing response message - Google Patents

Method, device, computer equipment and storage medium for uniformly processing response message Download PDF

Info

Publication number
CN110727537B
CN110727537B CN201911001292.XA CN201911001292A CN110727537B CN 110727537 B CN110727537 B CN 110727537B CN 201911001292 A CN201911001292 A CN 201911001292A CN 110727537 B CN110727537 B CN 110727537B
Authority
CN
China
Prior art keywords
request
response message
abnormal
preset
exception
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
Application number
CN201911001292.XA
Other languages
Chinese (zh)
Other versions
CN110727537A (en
Inventor
刘倍材
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Original Assignee
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd filed Critical Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority to CN201911001292.XA priority Critical patent/CN110727537B/en
Publication of CN110727537A publication Critical patent/CN110727537A/en
Application granted granted Critical
Publication of CN110727537B publication Critical patent/CN110727537B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention discloses a method, a device, computer equipment and a storage medium for uniformly processing response messages. The method comprises the following steps: if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter; acquiring the abnormality type and abnormality information of the request; generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end; if an abnormality of a request between Service and afterCompletion is detected, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format, so that the response message with a uniform format can be returned to the front end, the workload of the front end is reduced, and the front end is ensured to be capable of correctly analyzing the response message.

Description

Method, device, computer equipment and storage medium for uniformly processing response message
Technical Field
The present invention relates to the field of Spring MVC development technologies, and in particular, to a method, an apparatus, a computer device, and a storage medium for uniformly processing a response message.
Background
In the Spring MVC development process, most companies are in the application mode of front-end and back-end separation in use, the front end accesses the service of the back end, but the normal return result is also possible to encounter abnormal service codes, and the server cannot find the request and other conditions. The data response message formats returned to the front end in different cases are inconsistent, if the front end is required to parse the result types, the workload of the front end is certainly increased, and a greater problem is that: the data format of all response messages is not anticipated.
In the prior art, it is common practice to capture anomalies using annotations @ ExceptionHandler and @ ControllerAladidevice.
Referring to fig. 2, the exception request from Service to afterCompletion may be given to the exception class defined by @ ExceptionHandler for processing, and then a response message in a unified format is returned. However, since @ ExceptionHandler cannot handle the exception of the Filter layer (Filterpre and Filter after in FIG. 2), when the front end requests an exception at the Filter layer, the front end receives a response message in a different data format.
Disclosure of Invention
The embodiment of the invention provides a method, a device, computer equipment and a storage medium for uniformly processing response messages, which aim to solve the problem of inconsistent formats of response messages returned to a front end.
In a first aspect, an embodiment of the present invention provides a method for uniformly processing a response packet, including:
if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter;
acquiring the abnormality type and abnormality information of the request;
generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end;
if an abnormality of the request is detected to occur between the Service and the afterCompletion, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format.
The further technical scheme is that the obtaining the abnormality type and the abnormality information of the request includes:
the dopilter method is called to obtain the exception type of the request and exception information from ServletRequest.
The further technical scheme is that the generating a response message with a preset format according to the abnormality type and the abnormality information of the request comprises:
and generating a response message in a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information.
The response message template is provided with an abnormal type space and an abnormal information space, and the response message with a preset format is generated according to the pre-stored response message template, the abnormal type of the request and the abnormal information, and comprises the following steps:
and filling the abnormal type and the abnormal information of the request into the abnormal type blank and the abnormal information blank in the response message template respectively.
The further technical scheme is that the preset annotation is annotation @ ExceptionHandler.
In a second aspect, an embodiment of the present invention further provides an apparatus for uniformly processing a response packet, where the apparatus includes:
the jump unit is used for jumping the request to a preset abnormal Filter if detecting that the request is abnormal in the Filter layer;
the acquisition unit is used for acquiring the abnormality type and the abnormality information of the request;
the first generation unit is used for generating a response message in a preset format according to the abnormal type and the abnormal information of the request and sending the generated response message to the front end;
and the processing unit is used for processing the abnormality of the request by a preset annotation if detecting that the request is abnormal between Service and afterCompletion, wherein the format of a response message generated by the preset annotation is the preset format.
In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the method when executing the computer program.
In a fourth aspect, embodiments of the present invention also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the above method.
The embodiment of the invention provides a method, a device, computer equipment and a storage medium for uniformly processing response messages. Wherein the method comprises the following steps: if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter; acquiring the abnormality type and abnormality information of the request; generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end; if an abnormality of a request between Service and afterCompletion is detected, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format, so that the response message with a uniform format can be returned to the front end, the workload of the front end is reduced, and the front end is ensured to be capable of correctly analyzing the response message.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for uniformly processing response messages according to an embodiment of the present invention;
FIG. 2 is a flow diagram of request processing in the prior art;
FIG. 3 is a flow chart of request processing according to an embodiment of the invention;
FIG. 4 is a schematic block diagram of an apparatus for unified processing of response messages according to an embodiment of the present invention;
fig. 5 is a schematic block diagram of an obtaining unit of an apparatus for unified processing of response messages according to an embodiment of the present invention;
fig. 6 is a schematic block diagram of a first generating unit of an apparatus for uniformly processing response messages according to an embodiment of the present invention;
fig. 7 is a schematic block diagram of a second generating unit of an apparatus for uniformly processing a response packet according to an embodiment of the present invention;
fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Referring to fig. 1 and 3, fig. 1 is a schematic flowchart of a method for uniformly processing response messages according to an embodiment of the present invention. FIG. 3 is a flow chart illustrating request processing according to an embodiment of the invention.
Fig. 1 is a flowchart of a method for uniformly processing a response message according to an embodiment of the present invention. As shown, the method includes the following steps S1-S4.
S1, if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter.
In the embodiment of the invention, aiming at the defect that the annotation @ ExceptionHandler cannot capture the exception of the Filter, a Filter (a Filter) for processing errors (a type of dispatcherType. ERROR) is added by combining the characteristics of the Filter (the execution of the Filter is according to chained processing and different types of filters can process different requests), and the Filter is named as an error Filter for processing the exception which cannot be processed by the annotation @ ExceptionHandler and returning a response message with a uniform format.
In specific implementation, if an abnormality of a request occurs in a Filter layer, the request is skipped to a preset abnormality Filter (error Filter) so as to process the abnormality of the request by the abnormality Filter.
In a specific operation, when the SpringMVC item is started and loaded, the exception Filter (ErrorFilter) sets the dispatcherTypes as the dispatcherType, so that the SpringMVC automatically jumps to the exception Filter (ErrorFilter) when encountering the Filter layer exception.
S2, acquiring the abnormality type and abnormality information of the request.
In specific implementation, the exception type and the exception information of the request are obtained, so that a response message is generated according to the exception type and the exception information of the request.
In one embodiment, the step S2 specifically includes: the dopilter method is called to obtain the exception type of the request and exception information from ServletRequest. The dopilter method is a method in which a Filter (Filter) has a single method for processing requests and responses. The dopilter method accepts three input parameters: servlet Request, response, and Filter Chain objects. By calling the dopilter method, the exception type of the request and exception information can be obtained from ServletRequest.
S3, generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and sending the generated response message to the front end.
In specific implementation, a response message in a preset format is generated according to the abnormal type and the abnormal information of the request, and the generated response message is sent to the front end.
In one embodiment, the step S3 specifically includes the following steps: and generating a response message in a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information.
In a specific implementation, an abnormal type space and an abnormal information space are set in the response message template, and a response message with a preset format is generated according to a pre-stored response message template, the abnormal type of the request and the abnormal information, which specifically includes:
and filling the abnormal type and the abnormal information of the request into the abnormal type space and the abnormal information space in the response message template respectively, so that the response message with the uniform format can be generated.
S4, if the request is detected to be abnormal between Service and afterCompletion, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format.
In the implementation, if an abnormality of a request is detected to occur between Service and afterCompletion, the abnormality of the request is processed by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format.
In one embodiment, the preset annotation is an annotation @ ExceptionHandler.
The exception of the request from Service to afterCompletion can be handed to @ ExceptionHandler for processing, and then a response message is returned to the terminal. The format of the response message is the preset format.
The invention provides a method for uniformly processing response messages, which comprises the steps of jumping a request to a preset abnormal Filter if detecting that the request is abnormal in a Filter layer; acquiring the abnormality type and abnormality information of the request; generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end; if an abnormality of a request between Service and afterCompletion is detected, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format, so that the response message with a uniform format can be returned to the front end, the workload of the front end is reduced, and the front end is ensured to be capable of correctly analyzing the response message.
Fig. 4 is a schematic block diagram of an apparatus 70 for unified processing of response messages according to an embodiment of the present invention. As shown in fig. 4, the present invention further provides a device 70 for uniformly processing the response message, corresponding to the above method for uniformly processing the response message. The means 70 for uniformly processing the response message comprises means for performing the above-described method for uniformly processing the response message, which means may be arranged in a server. Specifically, referring to fig. 4, the apparatus 70 for unified processing of response messages includes a jumping unit 71, an obtaining unit 72, a first generating unit 73, and a processing unit 74.
A jumping unit 71, configured to, if an abnormality in the Filter layer is detected, jump the request to a preset abnormality Filter;
an acquisition unit 72 configured to acquire an abnormality type of the request and abnormality information;
a first generating unit 73, configured to generate a response message in a preset format according to the abnormality type and the abnormality information of the request, and send the generated response message to the front end;
and a processing unit 74, configured to process the request exception by a preset annotation if it is detected that the request exception occurs between Service and afterCompletion, where the format of the response message generated by the preset annotation is the preset format.
In one embodiment, as shown in fig. 5, the acquisition unit 72 includes a calling unit 721.
A calling unit 721, configured to call a dopilter method to obtain the exception type and the exception information of the request from ServletRequest.
In an embodiment, as shown in fig. 6, the first generating unit 73 includes a second generating unit 731.
The second generating unit 731 is configured to generate a response message in a preset format according to a pre-stored response message template, the abnormality type of the request, and the abnormality information.
In an embodiment, the response message template is provided with an anomaly type space and an anomaly information space, as shown in fig. 7, and the second generating unit 731 includes a filling unit 7311.
And a filling unit 7311, configured to fill the abnormality type and abnormality information of the request into an abnormality type space and an abnormality information space in the response message template, respectively.
It should be noted that, as will be clearly understood by those skilled in the art, the specific implementation process of the apparatus 70 and each unit for uniformly processing the response message may refer to the corresponding description in the foregoing method embodiment, and for convenience and brevity of description, the description is omitted here.
The means 70 for uniformly processing the response message may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 may be a terminal or a server, where the terminal may be an electronic device with a communication function, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster formed by a plurality of servers.
With reference to FIG. 8, the computer device 500 includes a processor 502, memory, and a network interface 505 connected by a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032, when executed, causes the processor 502 to perform a method for unified processing of response messages.
The processor 502 is used to provide computing and control capabilities to support the operation of the overall computer device 500.
The internal memory 504 provides an environment for the execution of a computer program 5032 in the non-volatile storage medium 503, which computer program 5032, when executed by the processor 502, causes the processor 502 to perform a method for unified processing of response messages.
The network interface 505 is used for network communication with other devices. Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of a portion of the architecture in connection with the present application and is not intended to limit the computer device 500 to which the present application is applied, and that a particular computer device 500 may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Wherein the processor 502 is configured to execute a computer program 5032 stored in a memory to implement the steps of:
if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter;
acquiring the abnormality type and abnormality information of the request;
generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end;
if an abnormality of the request is detected to occur between the Service and the afterCompletion, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format.
In one embodiment, when implementing the step of obtaining the exception type and the exception information of the request, the processor 502 specifically implements the following steps:
the dopilter method is called to obtain the exception type of the request and exception information from ServletRequest.
In an embodiment, when the step of generating the response message in the preset format according to the exception type and the exception information of the request is implemented by the processor 502, the following steps are specifically implemented:
and generating a response message in a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information.
In an embodiment, the response message template is provided with an abnormal type space and an abnormal information space, and when the processor 502 implements the step of generating the response message with the preset format according to the pre-stored response message template, the abnormal type of the request and the abnormal information, the specific implementation steps are as follows:
and filling the abnormal type and the abnormal information of the request into the abnormal type blank and the abnormal information blank in the response message template respectively.
It should be appreciated that in embodiments of the present application, the processor 502 may be a central processing unit (Central Processing Unit, CPU), the processor 502 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf Programmable gate arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that all or part of the flow in a method embodying the above described embodiments may be accomplished by computer programs instructing the relevant hardware. The computer program may be stored in a storage medium that is a computer readable storage medium. The computer program is executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present invention also provides a storage medium. The storage medium may be a computer readable storage medium. The storage medium stores a computer program. The computer program, when executed by a processor, causes the processor to perform the steps of:
if detecting that the request is abnormal in the Filter layer, jumping the request to a preset abnormal Filter;
acquiring the abnormality type and abnormality information of the request;
generating a response message in a preset format according to the abnormal type and the abnormal information of the request, and transmitting the generated response message to the front end;
if an abnormality of the request is detected to occur between the Service and the afterCompletion, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format.
In one embodiment, when the processor executes the computer program to implement the step of obtaining the type of abnormality and the abnormality information of the request, the processor specifically implements the following steps:
the dopilter method is called to obtain the exception type of the request and exception information from ServletRequest.
In one embodiment, when the processor executes the computer program to implement the step of generating the response message in a preset format according to the abnormality type and the abnormality information of the request, the processor specifically implements the following steps:
and generating a response message in a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information.
In an embodiment, an anomaly type space and an anomaly information space are provided in the response message template, and when the processor executes the computer program to implement the step of generating a response message in a preset format according to a pre-stored response message template, the anomaly type of the request and the anomaly information, the processor specifically implements the following steps:
and filling the abnormal type and the abnormal information of the request into the abnormal type blank and the abnormal information blank in the response message template respectively.
The storage medium may be a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, or other various computer-readable storage media that can store program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed.
The steps in the method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the invention can be combined, divided and deleted according to actual needs. In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The integrated unit may be stored in a storage medium if implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a terminal, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention.
In the foregoing embodiments, the descriptions of the embodiments are focused on, and for those portions of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (4)

1. A method for unified processing of response messages, comprising:
setting the dispatchertype of the exception Filter as dispatchertype, ERROR when the exception Filter is loaded, and jumping the request to the exception Filter if detecting that the request is abnormal in the Filter layer;
invoking a doFilter method to acquire the exception type and the exception information of the request from a servletRequest, wherein the doFilter method accepts three input parameters: servlet Request, response and Filter Chain objects;
generating a response message in a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information, and transmitting the generated response message to the front end;
if an abnormality of a request between Service and afterCompensation is detected, processing the abnormality of the request by a preset annotation, wherein the format of a response message generated by the preset annotation is the preset format, and the preset annotation is annotation @ Exception handler;
the response message template is provided with an abnormal type space and an abnormal information space, and the response message with a preset format is generated according to the pre-stored response message template, the abnormal type of the request and the abnormal information, and comprises the following steps:
and filling the abnormal type and the abnormal information of the request into the abnormal type blank and the abnormal information blank in the response message template respectively.
2. An apparatus for unified processing of response messages, comprising:
the jump unit is used for setting the dispatchertype of the exception Filter as dispatchertype when the exception Filter is loaded, and jumping the request to the exception Filter if the request is detected to be abnormal in the Filter layer;
the acquiring unit is used for calling a doFilter method to acquire the exception type and the exception information of the request from a ServletRequest, wherein the doFilter method accepts three input parameters: servlet Request, response and Filter Chain objects;
the first generation unit is used for generating a response message with a preset format according to a pre-stored response message template, the abnormal type of the request and the abnormal information, and transmitting the generated response message to the front end;
the processing unit is used for processing the abnormality of the request by a preset annotation if the abnormality of the request occurs between Service and afterCompaction is detected, wherein the format of a response message generated by the preset annotation is the preset format, and the preset annotation is annotation @ Exception handler;
wherein, the response message template is provided with an abnormal type space and an abnormal information space, and the first generating unit comprises:
and the filling unit is used for respectively filling the abnormal type and the abnormal information of the request into the abnormal type blank and the abnormal information blank in the response message template.
3. A computer device comprising a memory and a processor, the memory having stored thereon a computer program, the processor implementing the method of claim 1 when executing the computer program.
4. A computer readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of claim 1.
CN201911001292.XA 2019-10-21 2019-10-21 Method, device, computer equipment and storage medium for uniformly processing response message Active CN110727537B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911001292.XA CN110727537B (en) 2019-10-21 2019-10-21 Method, device, computer equipment and storage medium for uniformly processing response message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911001292.XA CN110727537B (en) 2019-10-21 2019-10-21 Method, device, computer equipment and storage medium for uniformly processing response message

Publications (2)

Publication Number Publication Date
CN110727537A CN110727537A (en) 2020-01-24
CN110727537B true CN110727537B (en) 2023-12-26

Family

ID=69220462

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911001292.XA Active CN110727537B (en) 2019-10-21 2019-10-21 Method, device, computer equipment and storage medium for uniformly processing response message

Country Status (1)

Country Link
CN (1) CN110727537B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113609012B (en) * 2021-07-30 2024-03-29 南京控维通信科技有限公司 Method and system for normalized processing back-end exception reporting

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009028342A1 (en) * 2007-08-28 2009-03-05 Nec Corporation Service providing system, filtering device, filtering method, and message check method
CN102271069A (en) * 2011-09-08 2011-12-07 北京网康科技有限公司 Method, device and system for detecting multi-dimensional information of users
CN108614763A (en) * 2016-12-09 2018-10-02 武汉斗鱼网络科技有限公司 A kind of adjustment method and device of application
CN108647107A (en) * 2018-05-14 2018-10-12 浪潮软件集团有限公司 Unified exception handling method for micro-service development framework
CN108737473A (en) * 2017-04-20 2018-11-02 贵州白山云科技有限公司 A kind of data processing method, apparatus and system
CN108762966A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 System exception hold-up interception method, device, computer equipment and storage medium
CN109408320A (en) * 2018-09-03 2019-03-01 中国平安人寿保险股份有限公司 Abnormality eliminating method, device, computer equipment and storage medium are developed in front end
CN109522222A (en) * 2018-10-26 2019-03-26 深圳点猫科技有限公司 It is a kind of for educating the exception catching method and device of cloud platform
CN110069297A (en) * 2019-03-28 2019-07-30 平安科技(深圳)有限公司 Abnormality eliminating method, device, computer equipment and storage medium based on Spring MVC

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009028342A1 (en) * 2007-08-28 2009-03-05 Nec Corporation Service providing system, filtering device, filtering method, and message check method
CN102271069A (en) * 2011-09-08 2011-12-07 北京网康科技有限公司 Method, device and system for detecting multi-dimensional information of users
CN108614763A (en) * 2016-12-09 2018-10-02 武汉斗鱼网络科技有限公司 A kind of adjustment method and device of application
CN108737473A (en) * 2017-04-20 2018-11-02 贵州白山云科技有限公司 A kind of data processing method, apparatus and system
CN108647107A (en) * 2018-05-14 2018-10-12 浪潮软件集团有限公司 Unified exception handling method for micro-service development framework
CN108762966A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 System exception hold-up interception method, device, computer equipment and storage medium
CN109408320A (en) * 2018-09-03 2019-03-01 中国平安人寿保险股份有限公司 Abnormality eliminating method, device, computer equipment and storage medium are developed in front end
CN109522222A (en) * 2018-10-26 2019-03-26 深圳点猫科技有限公司 It is a kind of for educating the exception catching method and device of cloud platform
CN110069297A (en) * 2019-03-28 2019-07-30 平安科技(深圳)有限公司 Abnormality eliminating method, device, computer equipment and storage medium based on Spring MVC

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"J2EE项目中一种新的错误处理方法";刘淑华;《计算机应用与软件》;143-146 *

Also Published As

Publication number Publication date
CN110727537A (en) 2020-01-24

Similar Documents

Publication Publication Date Title
CN111026774A (en) Data sequence synchronization method and device, computer equipment and storage medium
CN109684008B (en) Card rendering method, device, terminal and computer readable storage medium
CN110995539A (en) Business system monitoring method and device and computer equipment
US8694831B2 (en) Automatic bug reporting tool
CN110881224B (en) Network long connection method, device, equipment and storage medium
US20230030856A1 (en) Distributed table storage processing method, device and system
CN113986676A (en) Server health check method and device, electronic equipment and storage medium
CN111049883A (en) Data reading method, device and system of distributed table system
CN111199146B (en) Test report generation method, device, computer equipment and storage medium
CN110727537B (en) Method, device, computer equipment and storage medium for uniformly processing response message
CN109034668B (en) ETL task scheduling method, ETL task scheduling device, computer equipment and storage medium
CN110879756B (en) Collaborative process exception handling method, collaborative process exception handling device, computer equipment and storage medium
CN114003510A (en) Script testing method, device, equipment and medium based on Mock service
CN112380183B (en) Method and device for synchronizing distributed files, computer equipment and storage medium
CN111046393B (en) Vulnerability information uploading method and device, terminal equipment and storage medium
CN109688232B (en) Mirror image backtracking method, mirror image backtracking system and proxy server
CN115276844B (en) Communication module testing method and device, storage medium and electronic equipment
CN111176987A (en) Method and device for uniformly outputting front-end log, computer equipment and storage medium
CN110930253A (en) Intelligent contract internal main key generation method and device, computer equipment and storage medium
CN110989985B (en) Maven-based dependency package management method, device, computer equipment and storage medium
CN111090578B (en) Joint debugging method and device for engineering development, computer equipment and storage medium
JP5499484B2 (en) Program correction system, terminal device, server device, program correction method, error detection program, and management program
CN110597712B (en) Component attribute verification method, device, terminal and storage medium
CN108133149B (en) Data protection method and device and electronic equipment
CN111061613A (en) Front-end abnormity monitoring method and device and computer equipment

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