gpt4 book ai didi

jquery - session 变量和 RESTful api

转载 作者:行者123 更新时间:2023-12-01 01:07:36 27 4
gpt4 key购买 nike

我们正在逐步为我们的 Web 应用程序实现 REST 服务。目前,该应用程序是旧的程序风格类型应用程序。

新应用程序将采用 html5 格式,后端在 CF10 REST api 中实现,调用 cfc 返回 JSON 格式的对象。

我们需要通过 jquery 调用将 SESSION 变量传递给 REST cfc。有没有办法避免将 SESSION 变量作为 jquery 调用的参数?所有 REST cfc 都位于 Coldfusion10 的 Web 根目录中,因此 REST cfc 无法访问 SESSION 范围。

谢谢

最佳答案

我找到了以下关于 RESTful services in ColdFusion 的文档。特别参见第 4 点:

REST architectural principles:

A REST-based application follows some architectural principles:

  1. Resource identification: In REST-based architecture everything is a resource. You must identify each of these resources with an URI. In ColdFusion, you can make the functions you define in a CFC available as REST resources and you can access them using an URI.
  2. Uniform and constrained interface: Every resource in a RESTful application should support HTTP common operations i.e. the resources should be able to handle HTTP protocol methods – GET , PUT , POST and DELETE . In ColdFusion, you can access the resources (functions) via HTTP; each of these resources supports HTTP verbs. Depending on the verb specified in the request, the corresponding resource is invoked.
  3. Representation oriented: REST allows resources to have different representation – plain, HTML, XML, JSON, and so forth. A client can request a specific representation via the HTTP protocol. HTTP provides a simple content-type negotiation protocol between the client and the server. For example, an AJAX application may need data in JSON format, where as a Java application may need it in XML format.
  4. Stateless communication: In REST, the server doesn't store the client session data. However, many techniques exist to exchange state information such as URI rewriting, cookies, and hidden form fields. Also, for encryption, you can use REST on top of HTTPS.

还在 StackOverflow 上找到了有关它的讨论:

Way to maintain a session in a REST application

Website based on REST in ColdFusion

maintaining session in REST web service

Do sessions really violate RESTfulness?

关于jquery - session 变量和 RESTful api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20410968/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com