在Play 2中是否默认捕获所有通往新动作的路线? [英] Is there default catch all route to new actions in Play 2?

查看:80
本文介绍了在Play 2中是否默认捕获所有通往新动作的路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Play 1中,您定义的新操作具有默认路线.

In Play 1, new actions you defined had a default route.

*       /{controller}/{action}                  {controller}.{action}

(默认出现在新项目中)

(This appeared by default in new projects)

Play 2/2.1的等效功能是什么? 为什么它没有出现在默认路由文件中?

What is the Play 2/2.1 equivalent? Why doesn't it appear in the default routes file?

推荐答案

实际上,存在一条通行的路线.根据Play 2.0+中的路由文档,您可以使用动态部件跨越多个/,因此,如果将其准确地放在给定方法的最后条路线中,它将捕获之前未捕获的每条路线.如果您在数据库中存储了其他路由",则可以将其用于示例的进一步处理.

Actually there is a catch-all route available. According to the routing doc in Play 2.0+ you can use Dynamic parts spanning several / so if you put it as exactly last route of given method it will catch every route that wasn't catch before. You can use this for further processing for an example if you have other 'routes' stored in DataBase.

GET   /*path   controllers.Application.seacrhRouteInDB(path: String)

这篇关于在Play 2中是否默认捕获所有通往新动作的路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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