什么是反向路由? [英] What is reverse routing?
问题描述
真的,到处都提到了它,但是甚至没有维基百科页面以此命名.这只是URL重定向的奇特名称吗?它有其他名称或定义吗?
Really, it's mentioned everywhere but there is even no wikipedia page named exactly that. Is this just a fancy name for URL redirecting? Does it have another name or definition?
推荐答案
反向路由是生成URL的过程,该URL会给定对路径的符号引用(可以是route/view/控制器或对控制器的引用,具体取决于框架).
Reverse routing is the process of generating the URL that would lead to a route, given a symbolic reference to the route (could be name of the route/view/controller or a reference to the controller, depending on the framework).
(这是反向路由",因为它与常规路由或正向路由相反,后者从URL映射到指定视图或控制器的路由.)
(This is "reverse routing" because it's the opposite of normal routing or forward routing, which maps from a URL to a route specifying the view or controller.)
各种框架的示例:
- Django具有 URL模板标记和 urlresolvers.reverse helper方法
- flask具有 url_for
- Rails具有链接到
- Django has the url template tag and the urlresolvers.reverse helper method
- flask has url_for
- Rails has link_to
这篇关于什么是反向路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!