Summary of the invention
For solving the problem, the object of the present invention is to provide the synchronization module loading method of content on a kind of html page, cannot the problem of index to solve dynamic content on the html page.
For achieving the above object, technical scheme of the present invention is:
On the html page, a synchronization module loading method for content, comprises the steps:
Step one, the needs shown according to content, plan that the servers' data of each modularization content obtains interface;
Step 2, log-on data obtain interface to configuration file;
Step 3, the mark of carrying out html page patrix blocking content display region and description;
Step 4, provide a component engine in system server terminal, when the html page after having configured is accessed by the user, component engine can be tackled user's request, and analyzes the html page code structure of its request, therefrom filters out the dom element of mark data_render.
Further, in step one, carry out data-interface description, the citation form of provisioning modules content area data-interface and structure.
Further, in step 3, operationally dynamically obtain data the dynamic content region of displaying contents from server end to all on the html page and identify, identification means is that interpolation mark data_render is also its assignment on the dom element in this region, and its value is the name that servers' data obtains interface.
Further, in step 4, when client initiates request, server end is tackled request, and analyzes the html page of asking, data_render is used to filter page dom element, for the dom element be filled into, by the value of its data_render, at the example of its desired data interface of server end dynamic reflective, and obtain desired data by calling GetData method, be then attached in this dom element.
Compared to prior art, on the html page of the present invention, the synchronization module loading method of content can in the page of html type, and the modularization realizing dynamic content loads, and under solving the html page, dynamic content is to the disagreeableness problem of SEO.Same server-side data structure, by importing different parameters into, can load different data, shape paired data interface multiplexing.
Term " first ", " second " etc. in specification of the present invention and claims and above-mentioned accompanying drawing are for distinguishing similar object, and need not be used for describing specific order or precedence.Should be appreciated that the term used like this can exchange in the appropriate case, this is only describe in embodiments of the invention the differentiation mode that the object of same alike result adopts when describing.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, to comprise the process of a series of unit, method, system, product or equipment being not necessarily limited to those unit, but can comprise clearly do not list or for intrinsic other unit of these processes, method, product or equipment.
Below be described in detail respectively.
Please refer to shown in Fig. 1, Fig. 2, on the html page of the present invention, the synchronization module loading method of content, comprises the steps:
Step one, the needs shown according to content, plan that the servers' data of each modularization content obtains interface;
Carry out data-interface description, the citation form of provisioning modules content area data-interface and structure, on the corresponding page, the data-interface of modules content area realizes this interface.Data-interface defines requirement according to unified interface, mainly realizes GetData method.In the embodiment of the present invention, unified interface is defined as follows:
public?interface?IPortlet
{?public?string?GetData(object?param)
}
Step 2, log-on data obtain interface to configuration file
Title, procedure set reflection entrance is called by the mode registration interface of shape as <add name=" SinaRssNews " value=" GenerSoft.EPP.RSS.RSSReader, GenerSoft.EPP.RSS "/> in server end configuration file.The data-interface achieving IPortlet interface will describe in document at interface to be registered, and mainly indicates its name, value and params during registration, and wherein name is the unique invocation flags of its overall situation; Value is its program for .NET reflection and title.
Step 3, the mark of carrying out html page patrix blocking content display region and description
Operationally dynamically obtain data the dynamic content region of displaying contents from server end to all on the html page and identify, identification means is that interpolation mark data_render is also its assignment on the dom element in this region, and its value is the name that servers' data obtains interface; Params is its desired parameters, json character string type, the dom element after having configured, shape as:
<div?id="sina_news"?data_render="SinaRssNews"?params?=?"?{url:'http://',itemsCount:8}"?></div>
Step 4, provide a component engine in system server terminal, when the html page after having configured is accessed by the user, component engine can be tackled user's request, and analyzes the html page code structure of its request, therefrom filters out the dom element of mark data_render.
Particularly, when client initiates request, server end is tackled request, and analyze the html page of asking, use data_render to filter page dom element, for the dom element be filled into, by the value of its data_render, at the example of its desired data interface of server end dynamic reflective, and obtaining desired data by calling GetData method, being then attached in this dom element.Code is as follows:
public?class?PortletHandler?:?IHttpHandler
{
public?bool?IsReusable
{
Filter out all be marked with the dom element of data_render after, according to the value of data_render, get corresponding data-interface assembly name, and utilize this procedure set of reflex mechanism instantiation of .NET, and call its GetData method acquisition data, be filled into corresponding dynamic content region.After the data acquisition in all the elements region, component engine process after html content Response to client user's browser.
Through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required common hardware by software and realize, and can certainly comprise application-specific integrated circuit (ASIC), dedicated cpu, private memory, special components and parts etc. realize by specialized hardware.Generally, all functions completed by computer program can realize with corresponding hardware easily, and the particular hardware structure being used for realizing same function also can be diversified, such as analog circuit, digital circuit or special circuit etc.But under more susceptible for the purpose of the present invention condition, software program realizes is better execution mode.Based on such understanding, technical scheme of the present invention can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product is stored in the storage medium that can read, as the floppy disk of computer, USB flash disk, portable hard drive, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform method described in the present invention each embodiment.
In sum, above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit; Although with reference to above-described embodiment to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in the various embodiments described above, or carries out equivalent replacement to wherein portion of techniques feature; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.