WO2016206566A1 - 一种网页请求的处理方法、装置和系统 - Google Patents

一种网页请求的处理方法、装置和系统 Download PDF

Info

Publication number
WO2016206566A1
WO2016206566A1 PCT/CN2016/086104 CN2016086104W WO2016206566A1 WO 2016206566 A1 WO2016206566 A1 WO 2016206566A1 CN 2016086104 W CN2016086104 W CN 2016086104W WO 2016206566 A1 WO2016206566 A1 WO 2016206566A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
webpage request
request
information
webpage
Prior art date
Application number
PCT/CN2016/086104
Other languages
English (en)
French (fr)
Inventor
杨思枢
Original Assignee
阿里巴巴集团控股有限公司
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 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2016206566A1 publication Critical patent/WO2016206566A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs

Definitions

  • the embodiments of the present invention relate to network information processing technologies, and in particular, to a method, an apparatus, and a system for processing a webpage request.
  • MVC is a model for creating web applications using Model-View Controller (MVC) design: where Model is the part of the application that handles the logic of the application data, usually the model object is responsible for Access data in the database.
  • a view is the part of an application that processes the display of data. Usually the view is created from model data.
  • the Controller is the part of the application that handles user interaction. Usually the controller is responsible for reading data from the view, controlling user input, and sending data to the model.
  • the existing web development generally adopts the MVC mode.
  • the controller is used as a distribution controller for the front-end web page request, and the corresponding business method class needs to be defined according to the front-end web page request.
  • the Controller needs to continuously define the business method class, thus forming a large amount of redundant code and repeated development, resulting in reduced efficiency of web development.
  • the embodiments of the present invention provide a method, an apparatus, and a system for processing a webpage request, which are used to overcome the problem that the efficiency of web development is reduced due to a large amount of redundant code and repeated development in the prior art.
  • An embodiment of the present invention provides a method for processing a webpage request, including:
  • the controller receives a webpage request sent by the web front end and encapsulated according to a predefined package form
  • the object information and the method information included in the webpage request are information encrypted according to a pre-defined encryption manner
  • the acquiring object information and method information included in the webpage request includes:
  • the controller decrypts object information and method information included in the webpage request according to a decryption manner corresponding to the encryption method.
  • the webpage request further includes other service parameters, where the other service parameters are converted into corresponding strings by the web front end according to a preset format, where the preset format includes a json format.
  • the method includes:
  • the other service parameters included in the webpage request are deserialized into a parameter form recognized by the business model.
  • the embodiment of the invention provides a processing device for a webpage request, which is located on the controller side and includes:
  • a receiving module configured to receive a webpage request that is sent by the web front end and encapsulated according to a predefined package form
  • An obtaining module configured to acquire object information and method information included in the webpage request according to a decapsulation form corresponding to the encapsulated form
  • a determining module configured to determine, according to the object information, a service method class corresponding to the object information, and determine, according to the method information, a service method corresponding to the method information in the service method class;
  • a sending module configured to send the webpage request to a service model corresponding to the business method for corresponding processing.
  • the object information and the method information included in the webpage request are information encrypted according to a pre-defined encryption manner
  • the acquiring module is specifically configured to: decrypt the object information and the method information included in the webpage request according to a decryption manner corresponding to the encryption mode.
  • the webpage request further includes other service parameters, where the other service parameters are converted into corresponding strings by the web front end according to a preset format, where the preset format includes a json format.
  • the device further includes:
  • a conversion module configured to deserialize the other service parameters included in the webpage request into a parameter form recognized by the business model.
  • An embodiment of the present invention provides a processing system for a webpage request, including: a controller and a web front end;
  • the web front end is configured to detect a browser-triggered webpage request and package according to a predefined package form.
  • the webpage request and sending the encapsulated webpage request to the controller;
  • the controller includes processing means for the web page request described above.
  • the webpage request further includes other service parameters
  • the web front end is further configured to convert the other service parameters into a corresponding character string according to a preset format, where the preset format includes a json format.
  • the webpage request according to the pre-defined encapsulation form sent by the controller to the web front end is obtained by the controller; and the object information and the method information included in the webpage request are obtained according to the decapsulation form corresponding to the encapsulation form; Determining, according to the object information, a service method class corresponding to the object information, determining, according to the method information, a service method corresponding to the method information in the service method class; sending the webpage request to The service model corresponding to the service method performs corresponding service processing, and implements any webpage request sent by the controller to the web front end. Since any webpage request has a unified encapsulation form, the controller does not need to request for each webpage.
  • the corresponding business method class is defined, and the problem that the efficiency of web development caused by the repeated development of redundant code by the controller is reduced is solved.
  • Embodiment 1 is a flowchart of Embodiment 1 of a method for processing a webpage request according to the present invention
  • Embodiment 2 is a flowchart of Embodiment 2 of a method for processing a webpage request according to the present invention
  • Embodiment 3 is a schematic structural diagram of Embodiment 1 of a device for processing a webpage request according to the present invention
  • FIG. 4 is a schematic structural diagram of Embodiment 1 of a processing system for a webpage request according to the present invention.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information storage can be implemented by any method or technology.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
  • computer readable media does not include non-transitory computer readable media, such as modulated data signals and carrier waves.
  • FIG. 1 is a flowchart of Embodiment 1 of a method for processing a webpage request according to the present invention. As shown in FIG. 1, the method in this embodiment may include:
  • Step 101 The controller receives a webpage request that is encapsulated according to a predefined package form sent by the web front end.
  • the web front end defines a unified encapsulation form in advance, and the webpage request for triggering each service is uniformly encapsulated according to the foregoing predefined encapsulation form; thus, although the specific type and form of the webpage request of each service is different.
  • the form of the web page request after unified encapsulation is unified, for example, the web front end defines a coding method of a public web page request.
  • Step 102 Acquire object information and method information included in the webpage request according to a decapsulation form corresponding to the encapsulated form.
  • the controller only needs to define a common service method class corresponding to the uniformly encapsulated webpage request to decode the foregoing uniformly encoded webpage request, and obtain the object information included in the webpage request. And method information.
  • the controller needs to decrypt the object information and the method information included in the web page request according to the decryption method corresponding to the encryption method.
  • the webpage request further includes other service parameters
  • the web front end may convert other service parameters into corresponding strings according to a preset format, where the preset format includes a json format.
  • Step 103 Determine, according to the object information, a service method class corresponding to the object information, and determine, according to the method information, a service method corresponding to the method information in the service method class.
  • the controller After the controller acquires the object information and the method information included in the webpage request, Determining, according to the object information, a service method class corresponding to the object information, and determining, according to the method information, a service method corresponding to the method information in the service method class, that is, reflecting a service logic code of the calling back end .
  • Step 104 Forward the webpage request to a service model corresponding to the service method for corresponding processing.
  • the controller determines the service model according to the determined service method, and sends the webpage request to the corresponding service model, so that the service model performs corresponding service processing on the webpage request.
  • the controller may perform a deserialization of the other service parameters included in the webpage request into a parameter form recognized by the business model.
  • buttons when visiting a website webpage, the website webpage has different buttons, and these buttons will trigger different ajax requests in the background.
  • the urls defined by the ajax request are all kinds of various.
  • different classes or methods are also defined to accept the request sent by the front end.
  • the website webpage when accessing a website webpage, the website webpage has different buttons, and these buttons will trigger different ajax requests in the background.
  • the urls defined by the ajax request are various.
  • the ajax request of various urls is encapsulated.
  • the url of the encapsulated ajax request is uniform, except that the parameter bean and the method carried in the request are different, so that the controller only needs to be defined.
  • a class method which receives all the ajax requests from the front end, and then reflects according to the passed beans and methods, determines the corresponding business method, and forwards the ajax request to the business model corresponding to the business method for corresponding processing.
  • the webpage request according to the pre-defined encapsulation form sent by the controller to the web front end is obtained by the controller; and the object information and the method information included in the webpage request are obtained according to the decapsulation form corresponding to the encapsulation form; Determining, according to the object information, a service method class corresponding to the object information, determining, according to the method information, a service method corresponding to the method information in the service method class; sending the webpage request to The service model corresponding to the service method performs corresponding service processing, and implements any webpage request sent by the controller to the web front end. Since any webpage request has a unified encapsulation form, the controller does not need to request for each webpage.
  • the corresponding business method class is defined, and the problem that the efficiency of web development caused by the repeated development of redundant code by the controller is reduced is solved.
  • Embodiment 2 is a flowchart of Embodiment 2 of a method for processing a webpage request according to the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • Step 201 The web front end encapsulates the url request of the ajax according to the js method of the public ajax request, and sends the encapsulated data information to the controller.
  • the web front end defines a public ajax request js method
  • it is used to uniformly encapsulate the ajax url request triggered by the browser.
  • the following is an example of a public ajax request js method
  • WdmUtil.ajax function(method, bean, map, excute, url) ⁇
  • Method is the method information to be called by the back end, and based on security considerations, the method information can be encrypted in this embodiment;
  • the Bean is the object information to be called by the backend.
  • the object information may be encrypted in this embodiment.
  • Maps are other business parameters required by the ajax request, such as the user name or password entered by the user, which can be customized according to the specific service;
  • Excute is the method that is executed after the ajax request is completed, and the user can customize it;
  • the url is a special encapsulation operation that needs to be done in the ajax request, such as defining a new url that encapsulates the various urls in the ajax request.
  • the bean and the method are objects and methods for processing the specific business logic in the back end, and the encryption method is adopted to greatly reduce the risk of being attacked.
  • the present invention does not describe the specific encryption technology in detail, and may be an existing encryption technology. .
  • the web front end needs to convert other service parameters into corresponding strings according to a preset format, and the preset format includes the json format.
  • the web front end defines a public map conversion string js method, and the other incoming business parameters are converted from a map object into a json format string, such as: function mapToJson(map) ⁇ . Because in JS, the Map object is in the form of a key-value pair, it cannot be requested as a parameter on http, and must be converted into a string to be passed.
  • the web front end defines a js code snippet for a public ajax request:
  • Step 202 The controller decapsulates the ajax request sent by the web front end according to the predefined common business method class, acquires object information and method information in the ajax request, and reflects the business logic code of the calling back end.
  • the controller only needs to define a common service method class to decode the foregoing uniformly encoded ajax request, and obtain object information and method information included in the ajax request.
  • this public business method class implements the ApplicationContextAware interface, mainly rewriting the setApplicationContext(ApplicationContext applicationContext) method inside.
  • the container's context object information (applicationContext) is injected into the object. The purpose is to get all the object information of the backend service through the corresponding method of the interface after the application container is initialized.
  • the object information here corresponds to the bean sent by the web front end.
  • the controller may use the third party jar package gson, and call the gson.fromJson method to perform string reverse sequence. It is a Map ⁇ String, Object> object of Java, because the other business parameters that need to be sent by the method that calls the backend are Map ⁇ String, Object> objects.
  • the controller needs to decrypt the parameter bean and method into a normal string according to the corresponding decryption technology, and then use the reflection api (Class.getMethod) provided by java. Call the business logic layer (business model) of the back end.
  • the reflection call includes:
  • the controller defines a common business method class to reflect the main Java code snippets that call the back-end business logic code:
  • Step 203 The controller sends, according to the business logic code, other service parameters in the url request of the ajax to the corresponding business logic layer for corresponding processing.
  • the controller determines a corresponding business logic layer (service model) according to the service logic code invoked in the step 202, and sends the Map ⁇ String, Object> obtained in step 202 to the corresponding service model, so that the service model The ajax url requests the corresponding business processing.
  • service model business logic layer
  • the web front end encapsulates the ajax url request into a fixed format ajax request by using the public ajax request js method. After that, all other url requests do not need the controller to define the corresponding business method class and the business method one by one, so that The controller only needs to write a common business method class to reflect the business logic code class that calls the backend. Solve the problem of reduced efficiency of web development caused by a large number of repeated development of redundant code.
  • the parameter bean and the parameter method in the ajax request can be encrypted.
  • Embodiment 1 of a processing apparatus for a webpage request according to the present invention.
  • the apparatus of this embodiment may include:
  • the receiving module 31 is configured to receive a webpage request that is encapsulated according to a predefined package form sent by the web front end;
  • the obtaining module 32 is configured to acquire object information and method information included in the webpage request according to the decapsulation form corresponding to the packaged form;
  • a determining module 33 configured to determine, according to the object information, a service method class corresponding to the object information, and determine, according to the method information, a service method corresponding to the method information in the service method class;
  • the sending module 34 is configured to send the webpage request to a service model corresponding to the service method for corresponding processing.
  • the object information and the method information included in the webpage request are information encrypted according to a pre-defined encryption manner
  • the obtaining module 32 is specifically configured to: decrypt the object information and the method information included in the webpage request according to the decryption manner corresponding to the encryption mode.
  • the webpage request further includes other service parameters, where the other service parameters are converted into corresponding strings by the web front end according to a preset format, where the preset format includes a json format.
  • the device further includes:
  • the conversion module 35 is configured to perform deserialization of the other service parameters included in the webpage request into a parameter form recognized by the business model.
  • the device in this embodiment may be used to implement the technical solution of the method embodiment shown in FIG. 1 or FIG. 2, and the implementation principle and technical effects are similar, and details are not described herein again.
  • Embodiment 1 of a processing system for requesting a webpage according to the present invention including: a controller 41 and a web front end 42;
  • the web front end 42 is configured to detect a webpage request triggered by a browser, request the webpage encapsulated according to a predefined encapsulation form, and send the encapsulated webpage request to the controller;
  • the controller 41 includes the processing device for the web page request described in the embodiment shown in FIG.
  • the webpage request further includes other service parameters
  • the web front end 42 is further configured to convert the other service parameters into a corresponding character string according to a preset format, where the preset format includes a json format.
  • the device in this embodiment may be used to implement the technical solution of the method embodiment shown in FIG. 1 or FIG. 2, and the implementation principle and technical effects are similar, and details are not described herein again.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例提供一种网页请求的处理方法、装置和系统,包括:控制器接收web前端发送的根据预先定义的封装形式封装后的网页请求;根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。可以克服现有技术中存在大量冗余的代码和重复开发导致的web开发的效率降低的问题。

Description

一种网页请求的处理方法、装置和系统
本申请要求2015年06月26日递交的申请号为201510362984.2、发明名称为“一种网页请求的处理方法、装置和系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及网络信息处理技术,尤其涉及一种网页请求的处理方法、装置和系统。
背景技术
MVC是一种使用模型-视图-控制器(Model View Controller,MVC)设计创建Web应用程序的模式:其中,Model(模型)是应用程序中用于处理应用程序数据逻辑的部分,通常模型对象负责在数据库中存取数据。View(视图)是应用程序中处理数据显示的部分,通常视图是依据模型数据创建的。Controller(控制器)是应用程序中处理用户交互的部分,通常控制器负责从视图读取数据,控制用户输入,并向模型发送数据。
现有的web开发一般都采用MVC模式,在实现本发明的过程中发现:Controller作为前端网页请求的分发控制器,根据前端网页请求需要定义对应的业务方法类。基于现有的web业务开发方式,随着业务的不断发展,Controller需要不断的定义业务方法类,这样形成大量冗余的代码和重复开发,从而导致web开发的效率降低。
发明内容
本发明实施例提供一种网页请求的处理方法、装置和系统,用以克服现有技术中存在大量冗余的代码和重复开发导致的web开发的效率降低的问题。
本发明实施例提供一种网页请求的处理方法,包括:
控制器接收web前端发送的根据预先定义的封装形式封装后的网页请求;
根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;
根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;
将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。
可选地,所述网页请求中包括的对象信息和方法信息为根据预先定义的加密方式进行加密后的信息;
所述获取所述网页请求中包括的对象信息和方法信息包括:
所述控制器根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
可选地,所述网页请求中还包括其他业务参数,所述其他业务参数为所述web前端根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
可选地,将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理之前,包括:
将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
本发明实施例提供一种网页请求的处理装置,位于控制器侧,包括:
接收模块,用于接收web前端发送的根据预先定义的封装形式封装后的网页请求;
获取模块,用于根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;
确定模块,用于根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;
发送模块,用于将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。
可选地,所述网页请求中包括的对象信息和方法信息为根据预先定义的加密方式进行加密后的信息;
所述获取模块具体用于:根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
可选地,所述网页请求中还包括其他业务参数,所述其他业务参数为所述web前端根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
可选地,所述的装置还包括:
转化模块,用于将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
本发明实施例提供一种网页请求的处理系统,包括:控制器和web前端;
所述web前端,用于检测到浏览器触发的网页请求,根据预先定义的封装形式封装 的所述网页请求,并将所述封装后的网页请求发送给所述控制器;
所述控制器包括上述网页请求的处理装置。
可选地,所述网页请求中还包括其他业务参数;
所述web前端,还用于将所述其他业务参数根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
本实施例通过控制器对web前端发送的根据预先定义的封装形式封装后的网页请求;根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;之后,根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;将所述网页请求发送给与所述业务方法对应的业务模型进行相应的业务处理,实现了控制器对web前端发送的任一网页请求,由于任一网页请求都具有统一的封装形式,控制器不需要对每一个网页请求定义对应的业务方法类,解决控制器大量重复开发冗余代码导致的web开发的效率降低的问题。
附图说明
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:
图1为本发明一种网页请求的处理方法实施例一的流程图;
图2为本发明一种网页请求的处理方法实施例二的流程图;
图3为本发明一种网页请求的处理装置实施例一的结构示意图;
图4为本发明一种网页请求的处理系统实施例一的结构示意图。
具体实施方式
以下将配合附图及实施例来详细说明本申请的实施方式,藉此对本申请如何应用技术手段来解决技术问题并达成技术功效的实现过程能充分理解并据以实施。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
实施例描述
下面以一实施例对本申请方法的实现作进一步说明,图1为本发明一种网页请求的处理方法实施例一的流程图,如图1所示,本实施例的方法可以包括:
步骤101、控制器接收web前端发送的根据预先定义的封装形式封装后的网页请求。
本发明实施例中,web前端预先定义统一的封装形式,对触发每个业务的网页请求根据前述预先定义的封装形式进行统一的封装;这样,尽管每个业务的网页请求具体种类和形式是不同的,但是经过统一封装后的网页请求形式是统一,例如web前端定义一个公共的网页请求的编码方法。
步骤102、根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息。
在本发明一实施例中,控制器只需要对经过统一封装后的网页请求对应地定义一个公共的业务方法类用以解编码前述经过统一编码后的网页请求,获取网页请求中包括的对象信息和方法信息。
进一步地,假设Web前端对上述网页请求中的对象信息和方法信息经过加密处理的话,控制器需要根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
进一步地,所述网页请求中还包括其他业务参数,web前端可以根据预设格式将其他业务参数转化成为相应的字符串,其中,预设格式包括json格式。
步骤103、根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法。
对应地,本发明实施例中,控制器获取网页请求中包括的对象信息和方法信息之后, 根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法,即反射调用后端的业务逻辑代码。
步骤104、将所述网页请求转发给与所述业务方法对应的业务模型进行相应的处理。
对应地,控制器根据确定的业务方法确定业务模型,并将网页请求发送给对应的业务模型,以便业务模型对该网页请求进行相应的业务处理。
进一步地,当网页请求中还包括其他业务参数时,控制器可以将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
具体举例来说,在现有技术中,当去访问一个网站网页,网站网页里面有不同的按钮,这些按钮都会触发后台的不同的ajax请求,这种ajax请求定义的url都是各式各样的,在后台的控制器(controller)里也会定义不同的类或方法,来接受前端发过来的请求。
而根据图1所示实施例所述的方法,当去访问一个网站网页,网站网页里面有不同的按钮,这些按钮都会触发后台的不同的ajax请求,这种ajax请求定义的url都是各式各样的,首先是将各式各样的url的ajax请求进行封装,封装后的ajax请求的url是统一的,只不过请求中携带的参数bean和method不一样,这样,控制器只需要定义一个类一个方法,去接收前端的所有的ajax请求,进而根据传过来的bean和method进行反射,确定对应的业务方法,将ajax请求转发给与该业务方法对应的业务模型进行相应的处理。
本实施例通过控制器对web前端发送的根据预先定义的封装形式封装后的网页请求;根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;之后,根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;将所述网页请求发送给与所述业务方法对应的业务模型进行相应的业务处理,实现了控制器对web前端发送的任一网页请求,由于任一网页请求都具有统一的封装形式,控制器不需要对每一个网页请求定义对应的业务方法类,解决控制器大量重复开发冗余代码导致的web开发的效率降低的问题。
下面采用具体的实施例,对图1所示方法实施例的技术方案进行详细说明。
图2为本发明一种网页请求的处理方法实施例二的流程图,如图2所示,本实施例的方法可以包括:
步骤201、web前端根据公共的ajax请求的js方法对ajax的url请求进行封装,并将封装好的数据信息发送给控制器。
具体地,当web前端定义一个公共的ajax请求的js方法,用于对浏览器触发的ajax的url请求进行统一封装。以一个具体例子说明,如下是一个公共的ajax请求的js方法的实例
WdmUtil.ajax=function(method,bean,map,excute,url){}
其具体参数说明如下:
Method为后端所要调用的方法信息,基于安全考虑,本实施例中可以对该方法信息进行加密;
Bean为后端所要调用的对象信息,基于安全考虑,本实施例中可以对对象信息进行加密;
Map为ajax请求所需要的其他业务参数,例如用户输入的用户名或密码等信息,可以根据具体业务进行自定义;
excute为ajax请求完之后执行的方法,用户可以自定义;
url为需要在ajax请求里做特殊的封装操作,例如定义新的url,用于封装ajax请求中各式各样的url。
需要说明的是,bean和method是后端处理具体业务逻辑的对象和方法,采用加密的方式大大降低被攻击的风险,本发明对具体的加密技术不做详细描述,可以为现有的加密技术。
在这个例子中,ajax请求中包括其他业务参数时,web前端需要根据预设格式将其他业务参数转化成为相应的字符串,所述预设格式包括json格式。
具体地,web前端定义一个公共的map转化字符串的js方法,对传入的其他业务参数由map对象转化成json格式的字符串,如:function mapToJson(map){}。因为在js里,Map对象是键值对的形式存在,不能在http上作为参数请求,必须要转化成字符串的形式进行传递。
转化前的map对象:data:Object
app_id:12278902@android
app_version:all versions
转化后的json格式:{"app_id":"12278902@android","app_version":"all versions"}
举例来说,web前端定义一个公共的ajax请求的js代码片段:
Figure PCTCN2016086104-appb-000001
Figure PCTCN2016086104-appb-000002
步骤202、控制器根据预先定义的公共的业务方法类对web前端发送的ajax请求进行解封装,获取ajax请求中的对象信息和方法信息,并反射调用后端的业务逻辑代码。
具体地,控制器只需要定义一个公共的业务方法类用以解编码前述经过统一编码后的ajax请求,获取ajax请求中包括的对象信息和方法信息。
例如,这个公共的业务方法类要实现ApplicationContextAware这个接口,主要是对里面的setApplicationContext(ApplicationContext applicationContext)这个方法进行重写。把容器的上下文对象信息(applicationContext)注入到这个对象里面,目的是在应用容器初始化后是能通过这个接口对应的方法来拿到后端业务的所有对象信息。这里的对象信息与web前端发送过来的bean这个参数是对应的。
进一步地,当web前端发送过来的ajax请求中还包括其他业务参数时,即前端传过来的json参数,控制器例如可以利用gson这个第三方jar包,调用gson.fromJson这个方法进行字符串反序列化成Java的Map<String,Object>对象,因为调用后端的方法需要发送过来的其他业务参数统一是Map<String,Object>对象。
假设前端web对参数bean,method经过加密处理,则控制器需要根据对应的解密技术对参数bean,method进行解密还原成正常的字符串,再利用java自带的反射api(Class.getMethod),动态调用后端的业务逻辑层(业务模型)。
具体地,反射调用包括:
获得反射的对象信息:obj=applicationContext.getBean(bean)
获得反射的方法信息:me=obj.class.getMethod(method,
new Class[]{HashMap.class})
之后,进行反射调用:me.invoke(obj,map)
举例来说,控制器定义一个公共的业务方法类来反射调用后端的业务逻辑代码的主要Java代码片段:
Figure PCTCN2016086104-appb-000003
Figure PCTCN2016086104-appb-000004
步骤203、控制器根据业务逻辑代码,将ajax的url请求中的其他业务参数发送给对应业务逻辑层进行相应的处理。
对应地,控制器根据步骤202中反射调用的业务逻辑代码确定对应的业务逻辑层(业务模型),并将步骤202获取的Map<String,Object>发送给对应的业务模型,以便业务模型对该ajax的url请求进行相应的业务处理。
本实施例,web前端利用公共的ajax请求的js方法对ajax的url请求封装为固定格式ajax请求,之后,其他所有的url请求不需要控制器一一定义对应业务方法类和业务方法,这样,控制器只需要编写一个公共的业务方法类来反射调用后端的业务逻辑代码类就可以了。解决控制器大量重复开发冗余代码导致的web开发的效率降低的问题。
进一步地,为了保住业务安全可以对ajax请求中的参数bean和参数method进行加密处理。
图3为本发明一种网页请求的处理装置实施例一的结构示意图,如图3所示,本实施例的装置可以包括:
接收模块31,用于接收web前端发送的根据预先定义的封装形式封装后的网页请求;
获取模块32,用于根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;
确定模块33,用于根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;
发送模块34,用于将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。
可选地,所述网页请求中包括的对象信息和方法信息为根据预先定义的加密方式进行加密后的信息;
所述获取模块32具体用于:根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
可选地,所述网页请求中还包括其他业务参数,所述其他业务参数为所述web前端根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
可选地,假设所述网页请求中包括的其他业务参数,则在发送模块34将所述网页请 求发送给与所述业务方法对应的业务模型进行相应的处理之前,所述的装置还包括:
转化模块35,用于将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
本实施例的装置,可以用于执行图1或图2所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。
图4为本发明一种网页请求的处理系统实施例一的结构示意图,如图4所示,包括:控制器41和web前端42;
所述web前端42,用于检测到浏览器触发的网页请求,根据预先定义的封装形式封装的所述网页请求,并将所述封装后的网页请求发送给所述控制器;
所述控制器41包括图3所示实施例所述的网页请求的处理装置。
可选地,所述网页请求中还包括其他业务参数;
所述web前端42,还用于将所述其他业务参数根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
本实施例的装置,可以用于执行图1或图2所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (10)

  1. 一种网页请求的处理方法,其特征在于,包括:
    控制器接收web前端发送的根据预先定义的封装形式封装后的网页请求;
    根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;
    根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;
    将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。
  2. 根据权利要求1所述的处理方法,其特征在于,所述网页请求中包括的对象信息和方法信息为根据预先定义的加密方式进行加密后的信息;
    所述获取所述网页请求中包括的对象信息和方法信息包括:
    所述控制器根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
  3. 根据权利要求1所述的处理方法,其特征在于,所述网页请求中还包括其他业务参数,所述其他业务参数为所述web前端根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
  4. 根据权利要求1或3所述的处理方法,其特征在于,将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理之前,包括:
    将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
  5. 一种网页请求的处理装置,位于控制器侧,其特征在于,包括:
    接收模块,用于接收web前端发送的根据预先定义的封装形式封装后的网页请求;
    获取模块,用于根据与所述封装形式对应的解封装形式,获取所述网页请求中包括的对象信息和方法信息;
    确定模块,用于根据所述对象信息,确定与所述对象信息对应的业务方法类,根据所述方法信息,在所述业务方法类中确定与所述方法信息对应的业务方法;
    发送模块,用于将所述网页请求发送给与所述业务方法对应的业务模型进行相应的处理。
  6. 根据权利要求5所述的处理装置,其特征在于,所述网页请求中包括的对象信息和方法信息为根据预先定义的加密方式进行加密后的信息;
    所述获取模块具体用于:根据与所述加密方式对应的解密方式,解密所述网页请求中包括的对象信息和方法信息。
  7. 根据权利要求5所述的处理装置,其特征在于,所述网页请求中还包括其他业务参数,所述其他业务参数为所述web前端根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
  8. 根据权利要求5或7所述的处理装置,其特征在于,还包括:
    转化模块,用于将所述网页请求中包括的其他业务参数进行字符串反序列化为所述业务模型识别的参数形式。
  9. 一种网页请求的处理系统,其特征在于,包括:控制器和web前端;
    所述web前端,用于检测到浏览器触发的网页请求,根据预先定义的封装形式封装的所述网页请求,并将所述封装后的网页请求发送给所述控制器;
    所述控制器包括权利要求5-8任一项所述的网页请求的处理装置。
  10. 根据权利要求9所述的处理系统,其特征在于,所述网页请求中还包括其他业务参数;
    所述web前端,还用于将所述其他业务参数根据预设格式转化成为相应的字符串,所述预设格式包括json格式。
PCT/CN2016/086104 2015-06-26 2016-06-17 一种网页请求的处理方法、装置和系统 WO2016206566A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510362984.2 2015-06-26
CN201510362984.2A CN106293688B (zh) 2015-06-26 2015-06-26 一种网页请求的处理方法、装置和系统

Publications (1)

Publication Number Publication Date
WO2016206566A1 true WO2016206566A1 (zh) 2016-12-29

Family

ID=57584705

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/086104 WO2016206566A1 (zh) 2015-06-26 2016-06-17 一种网页请求的处理方法、装置和系统

Country Status (2)

Country Link
CN (1) CN106293688B (zh)
WO (1) WO2016206566A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109582908A (zh) * 2018-12-10 2019-04-05 郑州悉知信息科技股份有限公司 一种网页开发方法及装置

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885800B (zh) * 2019-02-20 2024-03-19 努比亚技术有限公司 数据处理方法、装置及计算机可读存储介质
CN112162755B (zh) * 2020-09-28 2023-03-31 抖音视界有限公司 一种数据处理方法、装置、介质和电子设备
CN112329415A (zh) * 2020-10-27 2021-02-05 江苏华邦网络科技有限公司 一种基于java web的出入参处理方法及系统
CN113467855B (zh) * 2021-06-24 2024-03-19 北京达佳互联信息技术有限公司 网页请求处理方法、装置、电子设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101694618A (zh) * 2009-09-01 2010-04-14 卡斯柯信号有限公司 适用于ajax框架的模型层与视图层数据自动映射方法
US20110161991A1 (en) * 2009-12-31 2011-06-30 Cbs Interactive, Inc. Controller and method to build a combined web page using data retrieved from multiple apis
CN102571731A (zh) * 2010-12-31 2012-07-11 德讯科技股份有限公司 一种面向对象的ajax框架模型系统及其处理方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100520717C (zh) * 2007-08-31 2009-07-29 南京联创科技股份有限公司 基于mvc的业务组装和页面模板化开发web平台的方法
CN102650952A (zh) * 2011-02-28 2012-08-29 北京航空航天大学 基于mvc框架的建模工具命令调用方法及系统
US10222926B2 (en) * 2012-03-19 2019-03-05 Citrix Systems, Inc. Systems and methods for providing user interfaces for management applications
CN102902537B (zh) * 2012-09-19 2016-03-30 厦门亿联网络技术股份有限公司 基于FastCGI和HTML模板的嵌入式WEB MVC开发框架
CN103809944A (zh) * 2012-11-08 2014-05-21 镇江华扬信息科技有限公司 一种基于jdbc的web数据库开发组件的方法
CN104270403A (zh) * 2014-09-01 2015-01-07 江苏西贝电子网络有限公司 基于struts2框架的云平台信息web监控系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101694618A (zh) * 2009-09-01 2010-04-14 卡斯柯信号有限公司 适用于ajax框架的模型层与视图层数据自动映射方法
US20110161991A1 (en) * 2009-12-31 2011-06-30 Cbs Interactive, Inc. Controller and method to build a combined web page using data retrieved from multiple apis
CN102571731A (zh) * 2010-12-31 2012-07-11 德讯科技股份有限公司 一种面向对象的ajax框架模型系统及其处理方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WANG, DONG ET AL.: "Analysis of Ajax-Based MVC Frame Transformation", JOURNAL OF COMPUTER APPLICATIONS, vol. 27, no. z1, 30 June 2007 (2007-06-30), pages 293 - 295, ISSN: 1001-9081 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109582908A (zh) * 2018-12-10 2019-04-05 郑州悉知信息科技股份有限公司 一种网页开发方法及装置

Also Published As

Publication number Publication date
CN106293688B (zh) 2019-09-06
CN106293688A (zh) 2017-01-04

Similar Documents

Publication Publication Date Title
WO2016206566A1 (zh) 一种网页请求的处理方法、装置和系统
CN106354481B (zh) 对http请求进行统一映射的方法和设备
US11223704B2 (en) Event service for local client applications through local server
JP6092249B2 (ja) 埋込まれたプロセス通信のための仮想チャネル
JP2020510329A (ja) ログイン情報処理の方法およびデバイス
US10579442B2 (en) Inversion-of-control component service models for virtual environments
US20220114250A1 (en) Client Device Information for Controlling Access to Web Applications
WO2019029455A1 (zh) 一种支付方法、装置及其设备
US9864528B2 (en) Data object observation among domain-restricted containers
US10560407B2 (en) Payload description for computer messaging
WO2017211190A1 (zh) 一种数据处理方法及装置
TW201732657A (zh) 業務執行方法及裝置
KR102147026B1 (ko) 애플리케이션 다운로드 방법 및 디바이스
WO2017092594A1 (zh) 一种信息处理方法及装置
US10903989B2 (en) Blockchain transaction processing method and apparatus
WO2020119265A1 (zh) 基于区块链的取证方法及装置
WO2019153492A1 (zh) 实现web与原生功能交互的方法、电子装置及可读存储介质
TW201528178A (zh) 資訊展示的方法及裝置
AU2012322684B2 (en) Event service for local client applications through local server
CN113253999B (zh) 插件化数据接入方法、数据源管理系统及接口接入方法
US20180102996A1 (en) Payload description for computer messaging
US20230090108A1 (en) Systematic identification and masking of private data for replaying user sessions
CN106648565B (zh) 一种请求发送方法及装置
WO2020221033A1 (zh) 管理设备对远端存储设备进行管理的方法
TW201734877A (zh) 基於應用程序的用戶資訊的隱藏方法及裝置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16813682

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16813682

Country of ref document: EP

Kind code of ref document: A1