Spring REST API 的路由与映射术语
Routing vs Mapping terminology for Spring REST API
我的问题很简单。在为 Spring REST API 资源定义 URL 路径时,您称它们为路由还是映射?那么,例如 https://www.myapp.com/api/person/123
会被称为个人资源的路由,还是个人资源的映射?我在研究这个问题时看到了这两个术语,它们似乎可以互换,但我想要一个实际的答案。我曾尝试搜索此内容,但似乎找不到与该主题相关的任何内容。
Spring 文档和 Spring 代码库一致使用术语:mapping
。
例如:
@RequestMapping
- "Annotation for mapping web requests onto specific handler classes and/or handler methods..."(我的重点)
- "The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings..."(我的重点)
- ...等等
相比之下,Spring MVC docs 没有提及 "routing" 或 "routes"。
但是,在一般用法中,术语 "routing" 是(至少以我的经验)~common ...
- 它充分描述了正在做的事情,即请求被某种调度程序路由到特定的控制器
- 其他框架(例如 Play Framework)使用术语 "routing" 和 "routes"
所以,我怀疑如果你使用那个术语,人们会理解你的意思,但是如果你想避免歧义,那么在 Spring REST API 的上下文中,更正确的形式是"mapping".
我的问题很简单。在为 Spring REST API 资源定义 URL 路径时,您称它们为路由还是映射?那么,例如 https://www.myapp.com/api/person/123
会被称为个人资源的路由,还是个人资源的映射?我在研究这个问题时看到了这两个术语,它们似乎可以互换,但我想要一个实际的答案。我曾尝试搜索此内容,但似乎找不到与该主题相关的任何内容。
Spring 文档和 Spring 代码库一致使用术语:mapping
。
例如:
@RequestMapping
- "Annotation for mapping web requests onto specific handler classes and/or handler methods..."(我的重点)
- "The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings..."(我的重点)
- ...等等
相比之下,Spring MVC docs 没有提及 "routing" 或 "routes"。
但是,在一般用法中,术语 "routing" 是(至少以我的经验)~common ...
- 它充分描述了正在做的事情,即请求被某种调度程序路由到特定的控制器
- 其他框架(例如 Play Framework)使用术语 "routing" 和 "routes"
所以,我怀疑如果你使用那个术语,人们会理解你的意思,但是如果你想避免歧义,那么在 Spring REST API 的上下文中,更正确的形式是"mapping".