【问题标题】:Variables in Play Framework routesPlay Framework 路由中的变量
【发布时间】:2015-12-22 11:44:03
【问题描述】:

在 Play Framework 1.3.x 中,可以在 routes file 中使用变量:

%{ context = play.configuration.getProperty('context', '') }%

# Home page
GET    ${context}         Secure.login

但是,这种方法似乎不适用于 Play 2.4。

在play 2.4中是否有可能在路由文件中设置变量?

提前致谢。

【问题讨论】:

  • 据我所知,这项功能已被遗憾地抛弃了,尽管您可以使用 advanced routing 东西来实现类似的功能。

标签: playframework routes playframework-2.4


【解决方案1】:

GET /poperties/:userId/:storeId @com.a.controllers.b.c(userId, storeId, propertyType:Int=7)

GET /poperties1/:userId/:storeId @com.a.controllers.b.c(userId, storeId, propertyType:Int=6)

propertyType 是一个变量。

【讨论】:

  • 这种方法只使用变量作为 url 的一部分并将其传递。我需要指定一个变量(例如在配置文件中),然后将其用作 url 本身的一部分。例如。像一个前缀。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-11
相关资源
最近更新 更多