CN107809383B - MVC-based path mapping method and device - Google Patents

MVC-based path mapping method and device Download PDF

Info

Publication number
CN107809383B
CN107809383B CN201610812509.5A CN201610812509A CN107809383B CN 107809383 B CN107809383 B CN 107809383B CN 201610812509 A CN201610812509 A CN 201610812509A CN 107809383 B CN107809383 B CN 107809383B
Authority
CN
China
Prior art keywords
file
name
function
routing
directory
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
CN201610812509.5A
Other languages
Chinese (zh)
Other versions
CN107809383A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201610812509.5A priority Critical patent/CN107809383B/en
Publication of CN107809383A publication Critical patent/CN107809383A/en
Application granted granted Critical
Publication of CN107809383B publication Critical patent/CN107809383B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/14Routing performance; Theoretical aspects
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (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 Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a path mapping method and a device based on MVC, which are used for obtaining a configuration file of a storage path comprising a routing file; acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file; storing the executive program corresponding to each function in a memory of a server; and storing the mapping relation between the function path and the storage position of the function in the server. The invention can realize the automatic storage of the mapping relation between the paths and the functions without manually configuring the mapping relation between the functions, thereby obviously improving the mapping speed between the functions and the paths. In addition, the invention stores the function in the memory of the server, when the received user accesses, the function can be quickly called from the memory, the time for reading the file is saved, and the access efficiency is effectively improved.

Description

MVC-based path mapping method and device
Technical Field
The invention relates to the technical field of internet, in particular to a path mapping method and device based on MVC.
Background
Software systems have been increasingly complex so far, much detail issues such as transaction processing, security, data flow control and the like need to be concerned when processing business logic, for example, to implement a user registration function, a server side needs to check data in security, such as SQL injection attack and XSS injection attack, and in addition, needs to control access frequency and the like, and after all the logics are completed, the logic for persisting user information to a database is executed, so that it can be seen that the logics are all universal and do not depend on business logic. MVC manual mapping refers to manually configuring the mapping of resource paths of user requests to routing function functions. The MVC is named as Model View Controller, is an abbreviation of Model (Model) -View (View) -Controller (Controller), is a software design paradigm, organizes codes by a method of separating business logic, data and interface display, and aggregates the business logic into one component, so that the business logic does not need to be rewritten while improving and personalizing a customized interface and user interaction. MVC was uniquely developed to map traditional input, processing, and output functions into a logical graphical user interface structure.
If the codes are added to each business logic, not only is the development workload increased, but also the later maintenance is not facilitated. In the prior art, the mapping is generally added by means of manual mapping. For example, function a is a routing function, and if a request with URL a is processed by function a, the mapping between a and a needs to be manually added in the program.
Aiming at the problem that path mapping can only be manually added in the related technology, an effective solution is not provided at present.
Disclosure of Invention
The inventors of the present invention found that: although the mapping relation in the prior art has no format limitation and can support many-to-one mapping relation, the mapping relation is very complicated, and the URL and the mapping relation are required to be manually set every time a routing function is added, so that the file structure cannot be organized according to modularization, is easy to make mistakes, and is not intuitive to view. In order to solve the problem, the invention provides a path mapping method based on MVC, which comprises the following steps:
acquiring a configuration file, wherein the configuration file comprises a storage path of a routing file;
acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file;
storing the executive program corresponding to each function in a memory of a server;
storing the mapping relation between the function path of the function name of the superior directory containing the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
Further, the configuration file further comprises: the method comprises the following steps of information of a data source and a page template file, wherein the information of the data source comprises: the IP address, port number, and database name of the database.
Further, the obtaining the routing file according to the configuration file includes:
and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Further, the directory name of the upper directory of the routing file is the module name in MVC.
Further, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
The invention also provides a request response method, which comprises the following steps:
receiving a request of a client; the request comprises a Uniform Resource Locator (URL);
analyzing the URL to acquire a file name in the URL, a superior directory name of the file and a function name;
searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
if so, acquiring the storage position of the function in the server according to the searched mapping relation;
the function is executed.
Further, if yes, after obtaining the storage location of the function in the server according to the found mapping relationship, the method further includes: if not, the request is refused to be responded.
Further, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
Correspondingly, the invention provides a MVC-based path mapping device, which comprises:
the configuration file acquisition module is used for acquiring a configuration file, wherein the configuration file comprises a storage path of a routing file;
the routing file acquisition module is used for acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file;
the storage module is used for storing the executive program corresponding to each function into a memory of the server;
the mapping module is used for storing the mapping relation between the function path of the directory name of the superior directory containing the routing file, the file name of the routing file, the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
Further, the routing file obtaining module is further configured to:
and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Further, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
The present invention also provides a request response device, including:
the request receiving module is used for receiving a request of a client; the request comprises a Uniform Resource Locator (URL);
the analysis module is used for analyzing the URL and acquiring a file name in the URL, a superior directory name of a file and a function name;
the searching module is used for searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
the position acquisition module is used for acquiring the storage position of the function in the server according to the searched mapping relation;
and the execution module is used for executing the function.
Further, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
In the embodiment of the invention, a configuration file comprising a storage path of a routing file is obtained; acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file; storing the executive program corresponding to each function in a memory of a server; and storing the mapping relation between the function path of the function name of the upper-level directory containing the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server. Therefore, the mapping relation between the path and the function is automatically stored, the mapping relation between the function is not required to be manually configured, and the mapping speed between the function and the path is obviously improved. In addition, the invention stores the function in the memory of the server, when the received user accesses, the function can be quickly called from the memory, the time for reading the file is saved, and the access efficiency is effectively improved.
The invention automatically establishes the mapping relation between the URL and the routing function, and determines the access URL when the routing function is compiled, thereby not only better managing the routing, but also saving the work of setting the mapping relation and making the directory structure clearer; the business logic is abstracted out and uniformly executed, and developers can concentrate on the development of the business logic, so that the development workload is greatly reduced. The developer simply organizes the file structure under the configured directory according to a certain specification and writes a routing function, which has already determined what URL requests will be processed by the function. Besides processing these logics, the MVC framework organizes the file structure according to the modular specification, realizes the conversion from Resource/Action to Controller/Method, and simplifies the processing logic.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a block diagram of a hardware structure of a computer terminal of an MVC-based path mapping method according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method for MVC-based path mapping in accordance with an embodiment of the present invention;
FIG. 3 is a flow diagram of a request response method according to an embodiment of the invention;
FIG. 4 is another flow diagram of a request response method according to an embodiment of the invention;
FIG. 5 is a schematic diagram of an MVC-based path mapping apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a request response device according to an embodiment of the present invention;
fig. 7 is a block diagram of a structure of a computer terminal according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with an embodiment of the present invention, there is provided an embodiment of an MVC-based path mapping method, it is noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the example of the present invention running on a computer terminal, fig. 1 is a block diagram of a hardware structure of a computer terminal according to an MVC-based path mapping method of an embodiment of the present invention. As shown in fig. 1, the computer terminal 100 may include one or more (only one shown) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, computer terminal 100 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the MVC-based path mapping method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 104, that is, implements the MVC-based path mapping method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 100. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
Under the operating environment, the application provides an MVC-based path mapping method as shown in FIG. 2. The method can be applied to intelligent terminal equipment, and is executed by a processor in the intelligent terminal equipment, and the intelligent terminal equipment can be an intelligent mobile phone, a tablet personal computer and the like. The intelligent terminal device is provided with at least one application program, and the embodiment of the invention does not limit the types of the application programs, and can be a system application program or a software application program.
Fig. 2 is a flowchart of an MVC-based path mapping method according to an embodiment of the present invention. As shown in fig. 2, an optional scheme of the MVC-based path mapping method includes the following steps:
step 201, obtaining a configuration file, where the configuration file includes a storage path of a routing file.
In the solution provided in step S201 of the present application, the service start is to initialize some data, objects, etc., and cache them for the service runtime to use; a database connection pool needs to be created, etc. The configuration file is information related to the environment and comprises information of a data source, a storage path of a routing file and a page template file; the information of the data source comprises: the IP address, port number and database name of the database; storing the configuration file in a memory; js is taken as an example, software needs to execute an entry file; the entry file and the configuration file are stored in different places, and the entry file needs to analyze the information of the configuration file. Js is a platform established based on Chrome JavaScript operation and is used for conveniently establishing network application with high response speed and easy expansion. Of course, Java, c + + or the like may be used in addition to the node.
Step S202, obtaining the routing file, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of each function in the routing file according to the configuration file.
As an optional implementation manner, in step S202, the obtaining a routing file according to a configuration file includes: and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Step S203, storing the execution program corresponding to each function in the memory of the server.
In the solution provided in the foregoing step S203, the executive program corresponding to the function refers to a source code of the executive program that can be directly read from the memory, that is, a machine language. The function is also called a method, and the execution program occupies very little memory space and can be ignored.
Step S204, storing the mapping relation between the function path of the function name of the upper directory containing the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server.
In the scheme provided in the foregoing step S204, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule. The directory name of the superior directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule, so that when the server receives an access request, the address can be analyzed according to the preset rule to obtain a function path, and the execution program of the function can be directly found according to the mapping relation between the function path and the storage position of the function in the server.
As an alternative implementation manner, in step S204, the directory name of the upper directory of the routing file is the module name in MVC. The module of the invention can be a login module, a registration module, a personal center and other functional modules. Storing the mapping relationship between the function path including the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file and the storage location of the function in the server means that the mapping relationship of the function path is configured in a configuration file.
As an alternative implementation manner, in step S204, the arranging, according to a predetermined rule, a directory name of an upper directory of the routing file, a file name of the routing file, and a function name of the routing file in the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
For example, in a certain MVC framework, a directory name at the next level of a module directory is a module name, where the module name is activity as an example, a controller directory is created under the activity directory, and the directory stores all routing files under the module, for example, a file named url is one of the routing files, and a redirect function is located in the url file and processes a jump, so that when a local service is started and a http:// localhost/activity/url/redirect request is accessed, a program automatically forwards a request to the redirect function for processing without manually configuring the mapping relationship.
In the solution of the present invention, a developer only needs to organize a file structure according to a predetermined specification under a configured directory and write a routing function, and thus it has been determined what URL request will be processed by the function, that is, according to the solution of the present invention, since a mapping relationship between a function path including a directory name of an upper directory of the routing file, a file name of the routing file, a function name of the routing file, and a storage location of the function in the server is stored, according to a URL request sent by a client, an execution program of the function can be directly found. When a routing function is added, the url and the mapping relation of the url do not need to be manually set, so that errors are not easy to occur, and the check is very intuitive.
The embodiment of the invention provides a path mapping method based on MVC, which comprises the steps of obtaining a configuration file of a storage path comprising a routing file; acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file; storing the executive program corresponding to each function in a memory of a server; and storing the mapping relation between the function path of the function name of the upper-level directory containing the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server. Therefore, the mapping relation between the path and the function is automatically stored, the mapping relation between the function is not required to be manually configured, and the mapping speed between the function and the path is obviously improved. In addition, the invention stores the function in the memory of the server, when the received user accesses, the function can be quickly called from the memory, the time for reading the file is saved, and the access efficiency is effectively improved. In addition, the invention realizes the modular organization of the directory structure; the manual configuration operation is saved, and the development efficiency is improved; the universal code and the service code are better separated, and the reusability of the codes can be improved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 2
According to an embodiment of the present invention, an embodiment of a request response method is provided. In the operating environment as in example 1, the present application provides a request response method as shown in fig. 3. Fig. 3 is a flow chart of a method of requesting a response according to an embodiment of the present invention. As shown in fig. 3, an alternative of the method for requesting a response includes the following steps:
step S301, receiving a request of a client; the request includes a uniform resource locator, URL.
In the solution provided by step S301 described above, the execution subject is a server, specifically, a distributor for uniformly receiving all requests. The request sent by the client may have various forms as long as the request for realizing data interaction is applicable to the present application, for example: links, http web page requests, protocols, etc.
Step S302, analyzing the URL, and acquiring a file name, a superior directory name and a function name of the file in the URL.
Step S303, searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is the mapping relation between the function path of the function name of the routing file and the storage position of the function in the server.
In the scheme provided in step S303, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule.
Optionally, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the method includes: in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
For example: the URL of the request must be in a format like http:// domain name/module name/file name/method name, otherwise it will not be recognized by the distributor. For example, one request is
The URL of http:// localhost/activity/URL/redirect is analyzed by the distributor to obtain the module name activity, the file name URL and the method name redirect, so that the request can be clearly known to be processed by the redirect method in the URL file under the activity directory, and before the service is started, the function path or the route is cached in the server memory, so that the distributor can find the execution program of the function from the memory according to the module name and the file name analyzed from the URL.
And step S304, if yes, acquiring the storage position of the function in the server according to the found mapping relation.
Step S305, the function is executed.
In the solution provided in step S305 of the present application, after the route is found, the specified function in the path may be executed according to the function name obtained through parsing, or referred to as a Method name, so that the conversion from Resource/Action to Controller/Method is completed.
As an alternative implementation, as shown in fig. 4, after step S304, the method further includes: step S306, if not, refusing to respond to the request.
In the solution provided in step S305, if the server does not search for the mapping relationship corresponding to the obtained file name, the upper directory name of the file, and the function name, it means that there is no mapping relationship of the cache path, or the resolved URL request does not conform to the predetermined format. At this point, the server may signal, for example, to deny the request.
The embodiment of the invention provides a request response method, which receives a request of a client; the request comprises a Uniform Resource Locator (URL); analyzing the URL to acquire a file name in the URL, a superior directory name of the file and a function name; searching a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name; the mapping relation is a mapping relation between a function path of a function name of a superior directory containing the routing file, a file name of the routing file and a storage position of the function in the server, and then the storage position of the function in the server is obtained according to the found mapping relation; the function is executed. According to the mapping relation of the function path pre-stored in the server, after the request is received, the storage position of the function in the memory is directly found from the file name obtained by analysis, the superior directory name of the file and the function name according to the mapping relation, so that the speed of responding to the request is obviously improved. In addition, due to the realization of the modular organization of the directory structure, the operation of manual configuration can be saved, the development efficiency is improved, the universal code and the service code are better separated, and the reusability of the code is improved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 3
According to the embodiment of the invention, the MVC-based path mapping device is also provided. As shown in fig. 5, the apparatus includes: the system comprises a configuration file acquisition module 10, a routing file acquisition module 20, a storage module 30 and a mapping module 40.
A configuration file obtaining module 10, configured to obtain a configuration file, where the configuration file includes a storage path of a routing file.
And a routing file obtaining module 20, configured to obtain, according to the configuration file, the routing file, a directory name of a higher-level directory of the routing file, a file name of the routing file, and a function name of each function in the routing file.
And a storage module 30, configured to store the execution program corresponding to each function in a memory of the server.
The mapping module 40 is configured to store a mapping relationship between a function path including a directory name of a higher-level directory of the routing file, a file name of the routing file, and a function name of the routing file, and a storage location of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
In the MVC-based path mapping apparatus of this embodiment, the configuration file obtaining module 10 is configured to execute step S201 in the embodiment of the present invention, the routing file obtaining module 20 is configured to execute step S202 in the embodiment of the present invention, the storage module 30 is configured to execute step S203 in the embodiment of the present invention, and the mapping module 40 is configured to execute step S204 in the embodiment of the present invention.
As an optional implementation manner, the routing file obtaining module 20 is further configured to: and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Optionally, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the method includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
Example 4
According to the embodiment of the invention, the invention also provides a request response device. As shown in fig. 6, the apparatus includes: a request receiving module 601, a parsing module 602, a searching module 603, a location obtaining module 604, and an executing module 605.
A request receiving module 601, configured to receive a request of a client; the request comprises a Uniform Resource Locator (URL);
the parsing module 602 is configured to parse the URL to obtain a file name in the URL, a superior directory name of a file, and a function name;
the searching module 603 is configured to search whether a mapping relationship corresponding to the obtained file name, a superior directory name of the file, and a function name exists; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
a location obtaining module 604, configured to obtain, according to the found mapping relationship, a storage location of the function in the server;
an execution module 605 for executing the function.
In the request responding apparatus of this embodiment, the request receiving module 601 is configured to execute step S301 in the embodiment of the present invention, the parsing module 602 is configured to execute step S302 in the embodiment of the present invention, the searching module 603 is configured to execute step S303 in the embodiment of the present invention, the location obtaining module 604 is configured to execute step S304 in the embodiment of the present invention, and the executing module 605 is configured to execute step S305 in the embodiment of the present invention.
Optionally, in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the method includes: in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
Example 5
The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the storage medium may be configured to store the program code executed by the MVC-based path mapping method according to the foregoing embodiment.
Optionally, in this embodiment, the storage medium may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
the first step is to obtain a configuration file, wherein the configuration file comprises a storage path of a routing file.
And secondly, acquiring the routing file, the directory name of the superior directory of the routing file, the file name of the routing file and the function name of each function in the routing file according to the configuration file.
And thirdly, storing the executive program corresponding to each function in a memory of the server.
Fourthly, storing the mapping relation between the function path of the directory name of the superior directory of the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Example 6
The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the storage medium may be configured to store a program code executed by the request response method according to the above embodiment.
Optionally, in this embodiment, the storage medium may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
the first step, receiving a request of a client; the request includes a uniform resource locator, URL.
And secondly, analyzing the URL to obtain the file name, the superior directory name and the function name of the file in the URL.
Thirdly, searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
And step four, if so, acquiring the storage position of the function in the server according to the searched mapping relation.
And step five, executing the function.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Example 7
The embodiment of the invention also provides a computer terminal, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computer terminal may be located in at least one network device of a plurality of network devices of a computer network.
Alternatively, fig. 7 is a block diagram of a structure of a computer terminal according to an embodiment of the present invention. As shown in fig. 7, the computer terminal a may include: one or more processors 161 (only one of which is shown), a memory 163, and a transmission device 165.
The memory 163 may be used to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for short text classification in the embodiments of the present invention, and the processor 161 executes various functional applications and data processing by executing the software programs and modules stored in the memory 163, that is, the short text classification is implemented. Memory 163 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 163 may further include memory located remotely from the processor 161, which may be connected to the computer terminal a via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 165 is used for receiving or transmitting data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmitting device 165 includes a network adapter that can be connected to a router via a network cable to communicate with the internet or a local area network. In one example, the transmission device 165 is a radio frequency module, which is used to communicate with the internet in a wireless manner.
Among them, the memory 163 is used to store, in particular, information of preset action conditions and preset authorized users, and application programs.
Processor 161 may invoke the information and applications stored by memory 163 via a transmission means to perform the following steps:
optionally, the processor 161 may further execute the following program codes:
the first step is to obtain a configuration file, wherein the configuration file comprises a storage path of a routing file.
And secondly, acquiring the routing file, the directory name of the superior directory of the routing file, the file name of the routing file and the function name of each function in the routing file according to the configuration file.
And thirdly, storing the executive program corresponding to each function in a memory of the server.
Fourthly, storing the mapping relation between the function path of the directory name of the superior directory of the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
Optionally, the specific examples in this embodiment may refer to the examples described in embodiment 1 and embodiment 3, and this embodiment is not described herein again.
Example 8
The embodiment of the invention also provides a computer terminal, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computer terminal may be located in at least one network device of a plurality of network devices of a computer network.
Alternatively, fig. 7 is a block diagram of a structure of a computer terminal according to an embodiment of the present invention. As shown in fig. 7, the computer terminal a may include: one or more processors 161 (only one of which is shown), a memory 163, and a transmission device 165.
The memory 163 may be used to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for short text classification in the embodiments of the present invention, and the processor 161 executes various functional applications and data processing by executing the software programs and modules stored in the memory 163, that is, the short text classification is implemented. Memory 163 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 163 may further include memory located remotely from the processor 161, which may be connected to the computer terminal a via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 165 is used for receiving or transmitting data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmitting device 165 includes a network adapter that can be connected to a router via a network cable to communicate with the internet or a local area network. In one example, the transmission device 165 is a radio frequency module, which is used to communicate with the internet in a wireless manner.
Among them, the memory 163 is used to store, in particular, information of preset action conditions and preset authorized users, and application programs.
Processor 161 may invoke the information and applications stored by memory 163 via a transmission means to perform the following steps:
optionally, the processor 161 may further execute the following program codes:
the first step, receiving a request of a client; the request includes a uniform resource locator, URL.
And secondly, analyzing the URL to obtain the file name, the superior directory name and the function name of the file in the URL.
Thirdly, searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule.
And step four, if so, acquiring the storage position of the function in the server according to the searched mapping relation.
And step five, executing the function.
Optionally, the specific examples in this embodiment may refer to the examples described in embodiment 2 and embodiment 4, which are not described herein again.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

Claims (13)

1. An MVC-based path mapping method, comprising:
acquiring a configuration file, wherein the configuration file comprises a storage path of a routing file;
acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file;
storing the executive program corresponding to each function in a memory of a server;
storing the mapping relation between the function path of the function name of the superior directory containing the routing file, the file name of the routing file and the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
2. The MVC-based path mapping method of claim 1, wherein the configuration file further comprises: the method comprises the following steps of information of a data source and a page template file, wherein the information of the data source comprises: the IP address, port number, and database name of the database.
3. The MVC-based path mapping method of claim 1, wherein the obtaining a routing file according to a configuration file comprises:
and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
4. The MVC-based path mapping method according to claim 1, wherein a directory name of an upper directory of the routing file is a module name in MVC.
5. A request response method, comprising:
receiving a request of a client; the request comprises a Uniform Resource Locator (URL);
analyzing the URL to acquire a file name in the URL, a superior directory name of the file and a function name;
searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file and the function name of the routing file are sequentially arranged;
if so, acquiring the storage position of the function in the server according to the searched mapping relation;
the function is executed.
6. The request response method according to claim 5, wherein if yes, after obtaining the storage location of the function in the server according to the found mapping relationship, the method further comprises: if not, the request is refused to be responded.
7. An MVC-based path mapping apparatus, comprising:
the configuration file acquisition module is used for acquiring a configuration file, wherein the configuration file comprises a storage path of a routing file;
the routing file acquisition module is used for acquiring a routing file, a directory name of a superior directory of the routing file, a file name of the routing file and a function name of each function in the routing file according to the configuration file;
the storage module is used for storing the executive program corresponding to each function into a memory of the server;
the mapping module is used for storing the mapping relation between the function path of the directory name of the superior directory containing the routing file, the file name of the routing file, the function name of the routing file and the storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged in sequence.
8. The MVC-based path mapping apparatus of claim 7, wherein the routing file obtaining module is further configured to:
and traversing the directory of the configuration file to search the routing file under the directory according to the path stored by the routing file set in the configuration file.
9. A request response device, comprising:
the request receiving module is used for receiving a request of a client; the request comprises a Uniform Resource Locator (URL);
the analysis module is used for analyzing the URL and acquiring a file name in the URL, a superior directory name of a file and a function name;
the searching module is used for searching whether a mapping relation corresponding to the acquired file name, the superior directory name of the file and the function name exists or not; the mapping relation is a mapping relation between a function path of a function name of a routing file and a function name of the routing file and a storage position of the function in the server; in the function path, the directory name of the upper-level directory of the routing file, the file name of the routing file and the function name of the routing file are arranged according to a preset rule;
in the function path, the directory name of the upper directory of the routing file, the file name of the routing file, and the function name of the routing file are arranged according to a predetermined rule, and the function path includes:
in the function path, the directory name of the superior directory of the routing file, the file name of the routing file and the function name of the routing file are sequentially arranged;
the position acquisition module is used for acquiring the storage position of the function in the server according to the searched mapping relation;
and the execution module is used for executing the function.
10. A terminal comprising a processor and a memory, the memory having stored therein program instructions that are loaded and executed by the processor to implement the MVC-based path mapping method of any of claims 1 to 4.
11. A computer-readable storage medium, having stored therein program instructions that are loaded and executed by a processor to implement the MVC-based path mapping method as recited in any of claims 1 to 4.
12. A server, comprising a processor and a memory, wherein program instructions are stored in the memory, loaded and executed by the processor to implement a request response method according to any of claims 5 to 6.
13. A computer-readable storage medium, having stored thereon program instructions that are loaded and executed by a processor to implement the request response method of any of claims 5 to 6.
CN201610812509.5A 2016-09-08 2016-09-08 MVC-based path mapping method and device Active CN107809383B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610812509.5A CN107809383B (en) 2016-09-08 2016-09-08 MVC-based path mapping method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610812509.5A CN107809383B (en) 2016-09-08 2016-09-08 MVC-based path mapping method and device

Publications (2)

Publication Number Publication Date
CN107809383A CN107809383A (en) 2018-03-16
CN107809383B true CN107809383B (en) 2020-06-26

Family

ID=61576259

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610812509.5A Active CN107809383B (en) 2016-09-08 2016-09-08 MVC-based path mapping method and device

Country Status (1)

Country Link
CN (1) CN107809383B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108549545A (en) * 2018-04-20 2018-09-18 武汉极意网络科技有限公司 A kind of project organization method and system based on tornado frames
CN110502232B (en) * 2018-05-16 2023-10-10 杭州海康威视系统技术有限公司 Routing address configuration method and device for page application
CN110597763B (en) * 2018-05-25 2022-06-03 杭州海康威视数字技术股份有限公司 Method and device for generating function index table
CN109271871A (en) * 2018-08-22 2019-01-25 平安科技(深圳)有限公司 Sample store path generation method, device, computer equipment and storage medium
CN109815112B (en) * 2018-12-14 2024-04-05 平安科技(深圳)有限公司 Data debugging method and device based on functional test and terminal equipment
CN110515905B (en) * 2019-08-28 2023-10-20 腾讯科技(深圳)有限公司 Method, device and server for configuring route
CN110674427B (en) * 2019-09-20 2022-04-22 北京达佳互联信息技术有限公司 Method, device, equipment and storage medium for responding to webpage access request
CN112000313A (en) * 2020-08-03 2020-11-27 北京达佳互联信息技术有限公司 Request response method, device, equipment and storage medium
CN113010224B (en) * 2021-03-03 2024-01-30 南方电网数字平台科技(广东)有限公司 Front-end micro-servitization method, front-end micro-servitization device, computer equipment and storage medium
CN113645138B (en) * 2021-08-09 2022-12-09 杭州安恒信息技术股份有限公司 Route configuration generation method and device, electronic equipment and storage medium
CN114077446B (en) * 2022-01-07 2022-04-08 宜科(天津)电子有限公司 Communication module calling system
CN114650251B (en) * 2022-03-18 2024-02-20 北京百度网讯科技有限公司 Routing table construction method, device, equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104765596A (en) * 2014-01-08 2015-07-08 腾讯科技(深圳)有限公司 Request handling method and device
CN104821954A (en) * 2015-03-27 2015-08-05 中国海洋大学 Cross-platform remote procedure call method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7146544B2 (en) * 2003-10-01 2006-12-05 Hewlett-Packard Development Company, L.P. Method and apparatus for supporting error handling in a web presentation architecture
US7581204B2 (en) * 2004-06-01 2009-08-25 Sap Ag Dynamic contexts
CN103412892B (en) * 2013-07-23 2018-05-04 百度在线网络技术(北京)有限公司 A kind of method and system for showing information

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104765596A (en) * 2014-01-08 2015-07-08 腾讯科技(深圳)有限公司 Request handling method and device
CN104821954A (en) * 2015-03-27 2015-08-05 中国海洋大学 Cross-platform remote procedure call method

Also Published As

Publication number Publication date
CN107809383A (en) 2018-03-16

Similar Documents

Publication Publication Date Title
CN107809383B (en) MVC-based path mapping method and device
KR102317535B1 (en) Methods and systems for implementing data tracking with software development kits
KR102105636B1 (en) Installing application remotely
CN106469044B (en) Method and device for realizing page jump
CN111399756B (en) Data storage method, data downloading method and device
CN107181779B (en) Method, device and system for processing access request
CN103645951A (en) Cross-platform mobile data management system and method
CN107947954B (en) System, method and server for dynamically adjusting log level
CN109600385B (en) Access control method and device
CN106534268B (en) Data sharing method and device
CN108540509B (en) Processing method and device of terminal browser, server and intelligent terminal
CN112887451B (en) Domain name resolution method and device and computer equipment
CN103973682A (en) Method and device for having access to webpage
CN113014681A (en) Network card binding method and device of multi-network card server, electronic equipment and storage medium
CN112416964A (en) Data processing method, device and system, computer equipment and computer readable storage medium
CN104618388A (en) Quick registration and login method and corresponding reset server and information server
CN111353136B (en) Method and device for processing operation request
CN110674427B (en) Method, device, equipment and storage medium for responding to webpage access request
CN103338233A (en) Load balancing device, Web server, request information processing method and system
US10324766B1 (en) Task profile collection
CN106936660B (en) Data acquisition method and device
CN104144170A (en) URL filtering method, device and system
CN115174248B (en) Control method and device for network access
CN111008220A (en) Dynamic identification method and device of data source, storage medium and electronic device
CN114253441B (en) Method and device for enabling target function, storage medium and electronic device

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