一般网络编程/设计问题:?
我已经从事网络编程两年了(自学 - 职业生物学研究员)。我设计了一个小型 wiki,其中包含所需的功能和科学的 RTE - 当然,很多是预期的。我使用了mootools框架 和 AJAX 广泛。
当我看到从 URL 传递的查询字符串时,我总是很好奇。长加密查询字符串直接传递到服务器。尤其是Google的设计就是这样。我认为这是向客户端提供 Web 服务的开始 - 我猜。
现在,我的问题是:这是一种特殊的、高度专业的、高效/先进的网页设计技术来通过 URL 传达查询吗?
我总觉得直接基于 URL 的通信速度更快。我尝试了一下,可以直接通过 URL 发送查询。这是链接:http://sgwiki.sdsc.edu/getSGMPage.php?8 通过这种方式,客户端可以直接链接到所需的页面而不是搜索和/或可以自动化。有很多可能性。
下一个请求:可以向我指出这样的网络编程技术吗? oops:抱歉,如果我没能清楚地表达我的要求。
普拉萨德。
I have been in web programming for 2 years (Self taught - a biology researcher by profession). I designed a small wiki with needed functionalities and a scientific RTE - ofcourse lot is expected. I used mootools framework
and AJAX extensively.
I was always curious when ever I saw the query strings passed from URL. Long encrypted query string directly getting passed to the server. Especially Google's design is such. I think this is the start of providing a Web Service to a client - I guess.
Now, my question is : is this a special, highly professional, efficient / advanced web design technique to communicate queries via the URL ?
I always felt that direct URL based communication is faster. I tried my bit and could send a query through the URL directly. here is the link: http://sgwiki.sdsc.edu/getSGMPage.php?8
By this , the client can directly link to the desired page instead of searching and / or can automate. There are many possibilities.
The next request: Can I be pointed to such technique of web programming?
oops: I am sorry, If I have not been able to convey my request clearly.
Prasad.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,不是真的,尽管可以。它曾经有一个整个应用程序的中心入口点。这是一种常见的做法,并且有各种好处,但显然不是必需的。通常,即使您看到的正常 url 也可能不是应用程序中实际的物理页面。路径的每个部分实际上可能通过服务器端的重写和路由映射到变量。例如,此问题的 URL:
http://stackoverflow.com/questions/2557535/general-web-programming-designing-question
可能会映射到类似
http://stackoverflow 的内容。 com/index.php?module=questions&action=view&question=2557535&title=general-web-programming-designing-question
拥有一个可以访问应用程序中所有功能的集中式页面是前端控制器模式的一部分,这是应用程序中的一种常见模式,通常用作整个模型、视图、控制器 (MVC) 模式的一部分。在 MVC 中,应用程序的关注点被划分为保存业务逻辑的模型。然后控制器使用这些模型来执行一组可以产生输出的任务。然后,该输出通过视图层呈现给客户端(浏览器、窗口管理器等)。
No not really, although it can be. Its used to have a central entry point to the entire application. Its a common practice and has all kinds of benefits, but its obviously not required. Often thes days though even a normal url you see may not actual be a physical page in the application.. each part of the path may actuall be mapped to a variable through rewriting and routing on the server side. For example the URL of this question:
http://stackoverflow.com/questions/2557535/general-web-programming-designing-question
Might map to something like
http://stackoverflow.com/index.php?module=questions&action=view&question=2557535&title=general-web-programming-designing-question
Having a centralized page through which all functions within an application are accessed is part of the Front Controller Pattern - a common pattern in applications generally used as part of the overall Model, View, Controller (MVC) pattern. In MVC, the concerns of the application are divided into the model which holds the business logic. These models are then used by the controller to perform a set of tasks which can produce output. This output is then rendered to the client (browser, window manager, etc..) via the view layer.
我认为您本质上要问的是查询字符串。在页面后面的url中,可能会有一个问号,后面可能会有URL参数(一般称为GET请求参数)。
一般在服务器端进行处理。例如,在 PHP 中,可以使用以下代码:
上述代码将是变量的值。或者,要在客户端执行此操作,可以使用锚点。将问号替换为井号 #
由于这是用于锚点,因此当 URL 更改为具有锚点标记时,页面不会刷新。这允许完全 AJAX 驱动的页面无需刷新即可操作 URL。此方法还经常用于启用 AJAX 页面的后退按钮支持。
在 JavaScript 中,可以使用 onload 处理程序作为读取页面 URL 并获取 URL 的哈希部分的机会。然后,该页面可以向服务器发出请求以读取任何必要的数据。
I think that essentially what you are asking about is query strings. In a url after a page, there may be a question mark after which, there may be URL parameters (generally called GET request parameters.)
Generally, processing this would be done on the server-side. For example, in PHP, one could use the following:
The aforementioned code would be the value of the variable. Alternatively, to do this client-side, one could use anchors. Replace the question mark with a hash sign #
Since this is used for anchors, when a URL is changed to have an anchor tag, the page is not refreshed. This allows for a completely AJAX-driven page to manipulate the URL without refreshing. This method is often used also for enabling back-button support for AJAX pages.
In JavaScript, one can use the onload handler as an opportunity to read the URL of the page and get the hash part of the URL. The page could then make a request back to the server to read any neccessary data.
这是使用前端控制器架构的结果。这与 wiki 的理念非常吻合,其中相同的代码用于呈现多个不同的 wiki 页面 - 内容由数据定义。
使用 URL 的查询部分作为页面选择标准并不是唯一的解决方案。例如,如果您使用 apache 那么您可以实现:
as
(您需要添加自己的解析来获取值。
或者,您可以使用 mod_rewrite 将路径中的组件映射回查询中。
没有特定的功能/性能 采用这些策略的原因。尽管建议在 URL 是幂等的情况下,每个页面都可以通过 GET 操作进行寻址(对于 SEO 也很有用)
。
It's a consequence of using a front controller architecture. This fits neatly with the idea of a wiki where the same code is used to render multiple different wiki pages - the content is defined by the data.
Using the query part of the URL for the page selection criteria is not the only solution. e.g. if you are using apache then you could implement:
as
(you'll need to add your own parsing to get the value out.
Alternatively, you can use mod_rewrite to map components out of the path back into the query.
There's no particular functional/performance reason for adopting any of these strategies. Although it is recommended, where the URL is idempotent, that each page be addressable via a GET operation (also useful for SEO).
C.