我想创建控制器方法并使用Class参数对其进行参数化以在路径中调用它:
GET /api/res1 controllers.GenericController.index(clazz:Class = Res1.class)
GET /api/res2 controllers.GenericController.index(clazz:Class = Res2.class)
并在编译期间播放:
[error] /home/../workspace/repo/prototype/conf/routes:26: identifier expected but 'class' found.
[error] /home/../workspace/repo/prototype/conf/routes:26: ')' expected but '}' found.
为什么'}' ?以及如何让我的想法发挥作用?
答案 0 :(得分:1)
尝试更改为:
/api/res1 controllers.GenericController.index(clazz: Class[_] = classOf[full.package.name.Res1])
对我来说效果很好。