什么是反向路由? [英] What is reverse routing?

查看:1607
本文介绍了什么是反向路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的,到处都提到了它,但是甚至没有维基百科页面以此命名.这只是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 has the url template tag and the urlresolvers.reverse helper method
  • flask has url_for
  • Rails has link_to

这篇关于什么是反向路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆