gpt4 book ai didi

java - JAX-RS/REST 资源究竟是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:08 25 4
gpt4 key购买 nike

“资源是 REST 中的基本概念之一。REST 强调对资源的操作,而不是发出函数调用。资源具有唯一标识符。在 HTTP 术语中,这意味着将每个资源与至少一个 URL 相关联。” https://cwiki.apache.org/confluence/display/WINK/JAX-RS+Resources,+HTTP+Methods,+and+Paths

我们将什么实现为资源?它是一组功能、一个对象、多个对象..?

最佳答案

The key abstraction of information in REST is a resource. Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in Los Angeles"), a collection of other resources, a non-virtual object (e.g. a person), and so on. In other words, any concept that might be the target of an author's hypertext reference must fit within the definition of a resource. A resource is a conceptual mapping to a set of entities, not the entity that corresponds to the mapping at any particular point in time.

This abstract definition of a resource enables key features of the Web architecture. First, it provides generality by encompassing many sources of information without artificially distinguishing them by type or implementation. Second, it allows late binding of the reference to a representation, enabling content negotiation to take place based on characteristics of the request. Finally, it allows an author to reference the concept rather than some singular representation of that concept, thus removing the need to change all existing links whenever the representation changes (assuming the author used the right identifier).

Fielding

What do we implement as a resource? Is it a group of functionalities, an object, multiple objects..?

几乎所有具有一种或多种表示形式的东西都可以序列化为字节流。

URI(统一资源标识符)的大多数设计指南都要求使用名词而不是动词,以资源是逻辑实体的论点来证明这一点。

关于java - JAX-RS/REST 资源究竟是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38152529/

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