Nothing Special   »   [go: up one dir, main page]

CN107704464A - Parse the method and device in the path of static resource - Google Patents

Parse the method and device in the path of static resource Download PDF

Info

Publication number
CN107704464A
CN107704464A CN201610643161.1A CN201610643161A CN107704464A CN 107704464 A CN107704464 A CN 107704464A CN 201610643161 A CN201610643161 A CN 201610643161A CN 107704464 A CN107704464 A CN 107704464A
Authority
CN
China
Prior art keywords
path
resource
static
requester
website
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.)
Granted
Application number
CN201610643161.1A
Other languages
Chinese (zh)
Other versions
CN107704464B (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201610643161.1A priority Critical patent/CN107704464B/en
Publication of CN107704464A publication Critical patent/CN107704464A/en
Application granted granted Critical
Publication of CN107704464B publication Critical patent/CN107704464B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiments of the invention provide a kind of method and device in the path for parsing static resource, this method includes:Obtain the resource path for the static resource that requestor requests access;If resource path is not present under the root path of the website of supplicant access, according to resource path, the Actual path of static resource is determined;The Actual path of static resource is returned into requesting party, so that requesting party loads the static resource according to the Actual path.If the path for solving static resource in the prior art is arranged to relative path, the problem of normal load static resource can be led to not, due to that the resource path of static resource can be arranged into relative path, when the address of website orientation needs modification, modified without the resource path to the static resource, when avoiding because using absolute path, when modification is needed in the address of website orientation, the problem of needing to modify to all absolute path, be advantageous to the deployment of website using the embodiment of inventive embodiments.

Description

Method and device for analyzing path of static resource
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for analyzing a path of a static resource.
Background
The contents of the address bar of the browser usually indicate the URL (uniform resource locator) of the currently browsed contents. In many cases, in order to clearly indicate the path, column or hierarchy of the currently browsed content, the URL usually uses a style in the form of RESTFul, for example, the address of a news list page is denoted as http://127.0.0.1/news, and this address is actually mapped to an actual Html file at the server end and returned, and this Html file is parsed by the browser, and when the browser loads the external resource in the Html file, the external resource is unloaded according to the path of the external resource.
In the Html file, the path types include: absolute path and relative path, using a relative path, usually written relative to the root path, e.g. when a picture is introduced, the address of the relative root path is written as: png, at which time loading static resources will not load normally, because the browser considers the path of the picture to be http://127.0.0.1/news/images/login, png, but in reality this path does not exist.
Aiming at the problem that the static resource cannot be loaded normally if the path of the static resource is set as a relative path in the prior art, an effective solution is not provided at present.
Disclosure of Invention
In view of the above, the present invention has been made to provide a method and apparatus for resolving paths of static resources that overcomes or at least partially solves the above problems.
In a first aspect, a method for resolving a path of a static resource is provided, including:
acquiring a resource path of a static resource which is requested to be accessed by a requester;
if the resource path does not exist under the root path of the website accessed by the requester, determining the actual path of the static resource according to the resource path;
and returning the actual path of the static resource to the requester so that the requester loads the static resource according to the actual path.
Optionally, the method further comprises:
judging whether the resource path exists under a root path of a website accessed by a requester;
and if the resource path exists under the root path of the website accessed by the requester, returning the resource path to the requester so that the requester loads the static resource according to the resource path.
Optionally, the determining an actual path of the static resource according to the resource path includes:
determining a resource path of an RESTFul style according to the resource path of the static resource;
and determining an actual path of the static resource under the root path of the website requested to be accessed according to the RESTFul style resource path.
Optionally, determining, according to the resource path of the RESTFul style, an actual path of the static resource under a root path of the website requested to be accessed, including:
deleting a dividing unit from the RESTFul-style resource path according to a preset sequence, wherein the RESTFul-style resource path comprises a plurality of dividing units obtained by dividing through separators;
judging whether the rest resource paths exist under the root path of the access request website;
if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website, and determining the residual path as the actual path.
Optionally, the obtaining a resource path of a static resource that a requester requests to access includes:
acquiring a request of the requester for accessing the website;
judging whether the resource requested to be accessed has static resource;
and if the resource requested to be accessed has the static resource, acquiring a resource path of the static resource.
In a second aspect, an apparatus for resolving a path of a static resource is further provided, including:
the acquisition module is used for acquiring a resource path of the static resource which is requested to be accessed by the requester;
the determining module is used for determining the actual path of the static resource according to the resource path if the resource path does not exist under the root path of the website accessed by the requester;
and the sending module is used for returning the actual path of the static resource to the requester so that the requester loads the static resource according to the actual path.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the resource path exists under the root path of the website accessed by the requester;
the sending module is further configured to, if the resource path exists under a root path of a website accessed by a requester, return the resource path to the requester, so that the requester loads the static resource according to the resource path.
Optionally, the determining module includes:
the analysis unit is used for determining a resource path of an RESTFul style according to the resource path of the static resource; and the determining unit is used for determining an actual path of the static resource under the root path of the website requested to be accessed according to the RESTFul style resource path.
Optionally, the determining unit is further configured to: deleting a dividing unit from the RESTFul-style resource path according to a preset sequence, wherein the RESTFul-style resource path comprises a plurality of dividing units obtained by dividing through separators; judging whether the rest resource paths exist under the root path of the website requested to be accessed; if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website requested to access, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website requested to access, and determining the residual path as the actual path.
Optionally, the obtaining module includes:
a first obtaining unit, configured to obtain a request for the requester to access the website;
the judging unit is used for judging whether the resource which is requested to be accessed has static resources or not;
and the second obtaining unit is used for obtaining a resource path of the static resource if the resource which is requested to be accessed has the static resource.
The embodiment of the invention has the beneficial effects that: if the resource path of the accessed static resource does not exist under the root path of the website accessed by the requester, the resource path of the static resource is converted into an actual path, and the actual path is returned to the requester, so that the requester can normally load the static resource according to the actual path, and the problem that the static resource cannot be normally loaded if the path of the static resource is set as a relative path in the prior art is solved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
FIG. 1 is a diagram illustrating a method for resolving paths of static resources according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of step 101 in a first embodiment of the present invention;
FIG. 3 is a schematic diagram of step 103 in the first embodiment of the present invention;
FIG. 4 is a second exemplary illustration of a method for resolving paths of static resources according to the first embodiment of the present invention;
FIG. 5 is a block diagram of an apparatus for resolving paths of static resources according to a second embodiment of the present invention;
fig. 6 is a second block diagram of an apparatus for resolving paths of static resources according to a second embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It is noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention, are intended to cover a non-exclusive inclusion, such as a list of steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article of manufacture, or apparatus.
It should be noted that the embodiments of the present invention and the features of the embodiments may be combined with each other without conflict. The technical solution of the present invention will be described in detail with reference to the accompanying drawings in conjunction with embodiments.
First embodiment
Fig. 1 is a flowchart of a method for resolving a path of a static resource according to an embodiment of the present invention, and as shown in fig. 1, the method for resolving a path of a static resource may include the following steps:
step 101, acquiring a resource path of a static resource requested to be accessed by a requester, and then entering step 103.
The requesting party may be an electronic device such as a computer, a mobile phone, a tablet computer, etc., and it should be noted that the specific type of the requesting party is not limited in this embodiment.
The static resource (staticlesource) determines an object or a value thereof after being compiled for the first time, and then cannot be modified, where the static resource may be a file such as css (cascading style sheet), js (javascript) of the website itself, or may also be a resource such as a picture in the website content, and it should be noted that the specific content of the static resource is not limited in this embodiment.
The resource path may be an absolute path of the resource, or may be a relative path of the resource, wherein,
absolute path, refers to a complete path. The absolute path of a resource represents: the address of the resource is an absolute address, such as http:// 127.0.0.1/login.png;
the relative path is the location positioning between different files in the same website. The referenced document is relative to the location of the current web page, from which relative path is derived. The relative path of the above resources may represent: the address of the resource is an address relative to the root path, for example, when a picture is introduced, the address relative to the root path is written as: png/images/logic.
The root path of the website is a logic packing path for storing website files in the website space, and the spaces provided by different space providers are different and the root path is also different.
In order to facilitate a better understanding of embodiments of the present invention by those skilled in the art, the following detailed description of absolute and relative paths is provided.
An absolute path refers to the path that a file really exists on the hard disk. For example, the picture of "bg. jpg" is stored in the directory of "E: \ book \ web page layout code \ chapter 2", and the absolute path of the picture of "bg. jpg" is "E: \ book \ web page layout code \ chapter 2 \ bg. gif". Then the following statement should be used if the background picture of the web page is to be specified using an absolute path:
< body backed ═ E: \ book \ web page layout \ code \ Chapter 2 \ bg. GIF' >)
The relative path is the position of the target file relative to the relative path. For example, in the above example, the "bg.jpg" picture is referred to in the "s 1. htm" file, and since the "bg.jpg" picture is in the same directory as that of the "s 1. htm", the picture can be correctly displayed in the browser no matter where the picture is uploaded to the Web server, if the relative positions of the two files are not changed (i.e., the picture is in the same directory) after the following code is used in the "s 1. htm" file.
<body background="bg.GIF">
As another example, if the directory in which the "s 1. htm" file is located is "E: \ book \ web page layout \ code \ chapter 2", and the directory in which the "bg. jpg" picture is located is "E: \ book \ web page layout \ code \ chapter 2 \ img", then the "bg. jpg" picture is in the "img" subdirectory of the directory in which the "s 1. htm" file is located, then the statement of referring to the picture should be:
<body background="img/bg.GIF">
it should be noted that the relative path uses the "/" character as the separator character of the directory, and the absolute path may use the "\" or "/" character as the separator character of the directory. Since the "img" directory is a subdirectory under the "chapter 2" directory, a "/" separator character is not added before "img".
A "/" is often used in the relative path to represent the upper level directory. If there are multiple superordinate directories, multiple "./" may be used, such as "http:// www.cnblogs.com/" to represent the superordinate directory. Assuming that the directory where the "s 1. htm" file is located is "E: \ book \ web page layout \ code \ chapter 2", and the directory where the "bg. jpg" picture is located is "E: \ book \ web page layout \ code", then the "bg. jpg" picture is in the higher-level directory of the directory where the "sg. htm" file is located, and the statement of referring to the picture should be:
<body background="../bg.GIF">
referring to fig. 2, step 101 may include step 1011, step 1013, and step 1015.
In step 1011, a request for the requester to access the website is acquired, and then step 1013 is entered.
The website may be a portal website, a government website or an enterprise official website, and it should be noted that the specific type of the website is not limited in this embodiment.
In step 1013, it is determined whether the resource requested to be accessed has a static resource, and if so, the process proceeds to step 1015; otherwise, return to step 1013;
in step 1015, if the resource requested to be accessed has a static resource, a resource path of the static resource is obtained.
For example: the path is requested so that the requestor loads the static resource according to the resource path.
Specifically, all requests with resource types of files are intercepted, for example, by writing an http request (which is a processing center of an http request), and then determining whether the requested resource is a static resource, if so, a resource path of the static resource is obtained.
Step 103, if the resource path does not exist under the root path of the website accessed by the requester, determining the actual path of the static resource according to the resource path, and then entering step 105.
In this embodiment, the actual path of the static resource refers to a path corresponding to the static resource existing under a root path of a website accessed by a requester, and the requester can normally load the static resource through the actual path.
Referring to fig. 3, step 103 includes: step 1031, step 1033, and step 1035.
Step 1031, determining a resource path of RESTFul style according to the resource path of the static resource, and then entering step 1033;
RESTFul style URLs: refers to organizing the URL of the accessed resource into a RESTFul style, and the URL is not the actual address of the resource and the backend needs mapping.
For example: the resource path is 127.0.0.1/test/home/login/images/login.png,
an alternative implementation is: dividing the resource path of the static resource into a plurality of units from left to right through separators, deleting a first unit '127.0.0.1' for the first time to obtain a resource path of a RESTFul style: png/test/home/login/images/login
Of course, it is understood that the resource path of the RESTFul style may be determined in other manners in the present embodiment. For example: in PHP, the domain name or IP address of the website in URL is generally obtained through $ _ SERVER [ 'HTTP _ HOST' ], for example, the resource path is 127.0.0.0.1/test/home/locations/images/locations.png, and the resource path in RESTFul style can be obtained through $ _ SERVER [ 'HTTP _ HOST' ] obtaining "/127.0.0.1" from 127.0.0.1/test/home/locations/images/locations.png and then deleting.
And 1033, determining an actual path of the static resource under the root path of the website requested to be accessed according to the RESTFul style resource path.
Specifically, in step 1033, a dividing unit is deleted from the RESTFul-style resource path according to a predetermined order, where the RESTFul-style resource path includes a plurality of dividing units divided by separators; judging whether the rest resource paths exist under the root path of the website requested to be accessed; if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website requested to access, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website requested to access, and determining the residual path as the actual path.
In connection with the example in step 1033, the RESTFul-style resource path "/test/home/logic/images/logic. png" includes the partitioning units "/test", "/home", "/logic", "/images", "/logic. png".
It should be noted that the resource paths of the static resources are separated by a delimiter '/', and each character string is a partition unit after separation. For example, the resource path of a static resource is: 127.0.0.1/test/logic.png, and the division units are 127.0.0.1, test and logic.png in sequence.
With continued reference to FIG. 1, step 105, the actual path of the static resource is returned to the requestor, so that the requestor loads the static resource according to the actual path.
Optionally, on the basis of fig. 1, the method further includes: step 107 and step 108, see fig. 4.
After step 101, go to step 107, in step 107, determine whether the resource path exists under the root path of the website accessed by the requester, if yes, go to step 103; otherwise step 108 is entered.
And step 108, if the resource path exists under the root path of the website accessed by the requester, returning the resource path to the requester so that the requester loads the static resource according to the resource path.
For example, the resource path of a static resource that is requested to be accessed is:
127.0.0.1/test/home/login/images/login.png
first, dividing each unit from left to right according to a separation symbol "/", deleting/127.0.0.1 for the first time to obtain a RESTFul style path: and the png is used for judging whether the residual path is existed under the root path, if not, deleting/test, judging whether the file exists, and if not, continuing the process until a real path of the file is found or the file does not exist.
In this embodiment, if the resource path of the static resource does not exist under the root path of the website accessed by the requester, the resource path of the static resource is converted into an actual path, and the actual path is returned to the requester, so that the requester can normally load the static resource according to the actual path, and the problem that the static resource cannot be normally loaded in the prior art is solved.
Second embodiment
Referring to fig. 5, an apparatus for resolving a path of a static resource is shown, the apparatus comprising: an acquisition module 501, a determination module 503 and a sending module 505. Wherein,
an obtaining module 501, configured to obtain a resource path of a static resource that a requester requests to access; the static resources include files such as css (cascading style sheet), js (javascript) and the like of the website itself, and also include resources such as pictures in the website content, and it should be noted that the specific content of the static resources is not limited in this embodiment. The resource path may be an absolute path of the resource, or may be a relative path of the resource, where the absolute path of the resource indicates: the address of the resource is an absolute address, such as http:// 127.0.0.1/login.png; the relative path of the resource may represent: the address of the resource is an address relative to the root path, for example, when a picture is introduced, the address relative to the root path is written as: png/images/logic.
A determining module 503, configured to determine, according to the resource path, an actual path of the static resource if the resource path does not exist under a root path of a website accessed by the requester. In this embodiment, the actual path of the static resource refers to a path corresponding to the static resource existing under the root path of the website, and the requester can normally describe the static resource through the actual path.
A sending module 505, configured to return the actual path of the static resource to the requestor, so that the requestor loads the static resource according to the actual path.
Optionally, in this embodiment, the sending module 506 is further configured to, if the resource path exists under a root path of a website accessed by a requester, return the resource path to the requester, so that the requester loads the static resource according to the resource path.
On the basis of fig. 5, optionally, the apparatus further includes: decision block 507, see fig. 6.
The determining module 507 is configured to determine whether the resource path exists under a root path of a website accessed by the requester.
On the basis of fig. 5, optionally, the determining module 503 includes: a parsing unit 5031 and a determining unit 5035, see fig. 6.
An analyzing unit 5031, configured to determine a resource path of a RESTFul style according to the resource path of the static resource;
a determining unit 5035, configured to determine, according to the resource path of the RESTFul style, an actual path of the static resource under the root path.
Optionally, the determining unit 5035 is further configured to: deleting a dividing unit from the RESTFul-style resource path according to a preset sequence, wherein the RESTFul-style resource path comprises a plurality of dividing units obtained by dividing through separators; judging whether the rest resource paths exist under the root path of the website requested to be accessed; if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website requested to access, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website requested to access, and determining the residual path as the actual path.
On the basis of fig. 5, optionally, the obtaining module 501 includes: the first acquiring unit 5011, the judging unit 5013, and the second acquiring unit 5015, see fig. 6.
A first obtaining unit 5011, configured to obtain a request of the requester to access the website;
a determining unit 5013, configured to determine whether the resource requested to be accessed has a static resource;
the second obtaining unit 5015 is configured to obtain a resource path of a static resource if the resource requested to be accessed has the static resource.
The device for analyzing the path of the static resource comprises a processor and a memory, wherein the acquisition module, the determination module, the sending module, the judgment module and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the problem that if the path of the static resource is set to be a relative path in the prior art, the static resource cannot be loaded normally is solved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
In this embodiment, if the resource path of the static resource does not exist under the root path of the website accessed by the requester, the resource path of the static resource is converted into an actual path, and the actual path is returned to the requester, so that the requester can normally load the static resource according to the actual path, and the problem that the static resource cannot be normally loaded in the prior art is solved.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: acquiring a resource path of a static resource which is requested to be accessed by a requester; if the resource path does not exist under the root path of the website accessed by the requester, determining the actual path of the static resource according to the resource path; and returning the actual path of the static resource to the requester so that the requester loads the static resource according to the actual path.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, 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 disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for resolving paths for static resources, comprising:
acquiring a resource path of a static resource which is requested to be accessed by a requester;
if the resource path does not exist under the root path of the website accessed by the requester, determining the actual path of the static resource according to the resource path;
and returning the actual path of the static resource to the requester so that the requester loads the static resource according to the actual path.
2. The method of claim 1, further comprising:
judging whether the resource path exists under a root path of a website accessed by a requester;
and if the resource path exists under the root path of the website accessed by the requester, returning the resource path to the requester so that the requester loads the static resource according to the resource path.
3. The method of claim 1, wherein determining the actual path of the static resource based on the resource path comprises:
determining a resource path of an RESTFul style according to the resource path of the static resource;
and determining an actual path of the static resource under the root path of the website requested to be accessed according to the RESTFul style resource path.
4. The method of claim 3, wherein determining the actual path of the static resource under the root path of the website requested to be accessed according to the RESTFul-style resource path comprises:
deleting a dividing unit from the RESTFul-style resource path according to a preset sequence, wherein the RESTFul-style resource path comprises a plurality of dividing units obtained by dividing through separators;
judging whether the rest resource paths exist under the root path of the access request website;
if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website, and determining the residual path as the actual path.
5. The method of claim 1, wherein obtaining the resource path of the static resource requested to be accessed by the requester comprises:
acquiring a request of the requester for accessing the website;
judging whether the resource requested to be accessed has static resource;
and if the resource requested to be accessed has the static resource, acquiring a resource path of the static resource.
6. An apparatus for resolving a path of a static resource, comprising:
the acquisition module is used for acquiring a resource path of the static resource which is requested to be accessed by the requester;
the determining module is used for determining the actual path of the static resource according to the resource path if the resource path does not exist under the root path of the website accessed by the requester;
and the sending module is used for returning the actual path of the static resource to the requester so that the requester loads the static resource according to the actual path.
7. The apparatus of claim 6, further comprising:
the judging module is used for judging whether the resource path exists under the root path of the website accessed by the requester;
the sending module is further configured to, if the resource path exists under a root path of a website accessed by a requester, return the resource path to the requester, so that the requester loads the static resource according to the resource path.
8. The apparatus of claim 6, wherein the determining module comprises:
the analysis unit is used for determining a resource path of an RESTFul style according to the resource path of the static resource;
and the determining unit is used for determining an actual path of the static resource under a root path of the website accessed by the requester according to the RESTFul style resource path.
9. The apparatus of claim 8, wherein the determining unit is further configured to: deleting a dividing unit from the RESTFul-style resource path according to a preset sequence, wherein the RESTFul-style resource path comprises a plurality of dividing units obtained by dividing through separators; judging whether the rest resource paths exist under the root path of the website requested to be accessed; if the resource path does not exist, continuing to delete the next dividing unit from the RESTFul-style resource path according to a preset sequence, then judging whether the residual resource path exists under the root path of the website requested to access, if the resource path does not exist, continuing the process until the residual resource path exists under the root path of the website requested to access, and determining the residual path as the actual path.
10. The apparatus of claim 6, wherein the obtaining module comprises:
a first obtaining unit, configured to obtain a request for the requester to access the website;
the judging unit is used for judging whether the resource which requests to be accessed has static resource;
and the second acquisition unit is used for acquiring a resource path of the static resource if the resource which is requested to be accessed has the static resource.
CN201610643161.1A 2016-08-08 2016-08-08 Method and device for analyzing path of static resource Active CN107704464B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610643161.1A CN107704464B (en) 2016-08-08 2016-08-08 Method and device for analyzing path of static resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610643161.1A CN107704464B (en) 2016-08-08 2016-08-08 Method and device for analyzing path of static resource

Publications (2)

Publication Number Publication Date
CN107704464A true CN107704464A (en) 2018-02-16
CN107704464B CN107704464B (en) 2021-05-07

Family

ID=61168620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610643161.1A Active CN107704464B (en) 2016-08-08 2016-08-08 Method and device for analyzing path of static resource

Country Status (1)

Country Link
CN (1) CN107704464B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008182A (en) * 2019-04-15 2019-07-12 山东浪潮云信息技术有限公司 A kind of method that static resource is saved and generated in document
CN113055443A (en) * 2021-02-20 2021-06-29 北京奇艺世纪科技有限公司 Resource data deployment method, device, equipment and storage medium
CN117076010A (en) * 2023-09-15 2023-11-17 腾讯科技(深圳)有限公司 Program module processing method, apparatus, device and computer readable storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7293012B1 (en) * 2003-12-19 2007-11-06 Microsoft Corporation Friendly URLs
CN101242229A (en) * 2008-03-17 2008-08-13 北京创毅视讯科技有限公司 A data transmission method and terminal in mobile multimedia broadcasting system
CN101576908A (en) * 2009-03-12 2009-11-11 北京中星微电子有限公司 Method and system for acquiring file handle by file name
CN101763418A (en) * 2009-12-16 2010-06-30 中兴通讯股份有限公司 File resource access method and device
CN102214224A (en) * 2011-06-15 2011-10-12 中兴通讯股份有限公司 Network resource access optimizing method, Web page browser and terminal
CN103491451A (en) * 2013-09-26 2014-01-01 深圳Tcl新技术有限公司 Method and device for obtaining webpage data
CN103685400A (en) * 2012-09-17 2014-03-26 联想(北京)有限公司 Information processing method, server and electronic equipment
CN104573001A (en) * 2015-01-07 2015-04-29 北京联合大学 Mobile terminal-based webpage data acqusition and classification method
CN104978373A (en) * 2014-06-09 2015-10-14 腾讯科技(深圳)有限公司 Webpage display method and webpage display device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7293012B1 (en) * 2003-12-19 2007-11-06 Microsoft Corporation Friendly URLs
CN101242229A (en) * 2008-03-17 2008-08-13 北京创毅视讯科技有限公司 A data transmission method and terminal in mobile multimedia broadcasting system
CN101576908A (en) * 2009-03-12 2009-11-11 北京中星微电子有限公司 Method and system for acquiring file handle by file name
CN101763418A (en) * 2009-12-16 2010-06-30 中兴通讯股份有限公司 File resource access method and device
CN102214224A (en) * 2011-06-15 2011-10-12 中兴通讯股份有限公司 Network resource access optimizing method, Web page browser and terminal
CN103685400A (en) * 2012-09-17 2014-03-26 联想(北京)有限公司 Information processing method, server and electronic equipment
CN103491451A (en) * 2013-09-26 2014-01-01 深圳Tcl新技术有限公司 Method and device for obtaining webpage data
CN104978373A (en) * 2014-06-09 2015-10-14 腾讯科技(深圳)有限公司 Webpage display method and webpage display device
CN104573001A (en) * 2015-01-07 2015-04-29 北京联合大学 Mobile terminal-based webpage data acqusition and classification method

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
SOUTH-FLY: "Spring MVC Restful构建中静态资源访问问题", 《HTTPS://BLOG.CSDN.NET/SUNLOVEFLY2008/ARTICLE/DETAILS/47055173?UTM_MEDIUM=DISTRIBUTE.PC_RELEVANT.NONE-TASK-BLOG-OPENSEARCH-1.CHANNEL_PARAM&DEPTH_1-UTM_SOURCE=DISTRIBUTE.PC_RELEVANT.NONE-TASK-BLOG-OPENSEARCH-1.CHANNEL_PARAM》 *
YANJUNLU: "用html的base标签,解决静态资源、请求的相对路径问题", 《HTTPS://BLOG.CSDN.NET/YANJUNLU/ARTICLE/DETAILS/7997020》 *
刘俊: "面向资源构架的就业管理信息系统研究与设计", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
平凡希: "SpringMVC访问静态资源的三种方式", 《HTTPS://BLOG.CSDN.NET/U012730299/ARTICLE/DETAILS/51872704》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008182A (en) * 2019-04-15 2019-07-12 山东浪潮云信息技术有限公司 A kind of method that static resource is saved and generated in document
CN113055443A (en) * 2021-02-20 2021-06-29 北京奇艺世纪科技有限公司 Resource data deployment method, device, equipment and storage medium
CN117076010A (en) * 2023-09-15 2023-11-17 腾讯科技(深圳)有限公司 Program module processing method, apparatus, device and computer readable storage medium
CN117076010B (en) * 2023-09-15 2024-01-19 腾讯科技(深圳)有限公司 Program module processing method, apparatus, device and computer readable storage medium

Also Published As

Publication number Publication date
CN107704464B (en) 2021-05-07

Similar Documents

Publication Publication Date Title
EP3606010B1 (en) Method and apparatus for processing web application package
CN107391535B (en) Method and device for searching document in document application
CN103631905A (en) Webpage loading method and browser
CN107704464B (en) Method and device for analyzing path of static resource
CN107040606B (en) Method and device for processing http request
CN107147645B (en) Method and device for acquiring network security data
JP2018519575A (en) Page jump based on text hiding
CN112612982A (en) Webpage preloading method and device and computer equipment
CN106202083A (en) Resource packaging system, method and device for web page
CN111328394A (en) Locally secure rendering of WEB content
CN116303309A (en) File mounting method and device and electronic equipment
CN111309432B (en) Fault drilling method, device and system
JP2019511060A (en) Method and apparatus for page display
CN110020343B (en) Method and device for determining webpage coding format
CN103685518A (en) Method, client side and system for providing image-text pages for mobile terminal
CN111124525A (en) Website function implementation method and device
EP2686791B1 (en) Variants of files in a file system
CN105718279A (en) Firefox based OS application generation method and apparatus
CN111813416B (en) File packing method, device and equipment and storage medium
CN110708270B (en) Abnormal link detection method and device
CN113449216A (en) File processing method and device and storage medium
CN112579947A (en) Webpage element graph intercepting method and device and electronic equipment
CN108255878B (en) User information processing method and related device
CN107103001B (en) Method, device and system for acquiring target front-end resource file based on browser
CN113312314A (en) Method, device and equipment for android platform repeated file retrieval

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