![](/img/trans.png)
[英]Play Framework 2.3.4 - How to call Results.badRequest() on a POST request and direct to method in controller not mapped by routes?
[英]Play framework - call controller in routes with Class parameter
我想创建控制器方法并使用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.
为什么是'}'? 以及如何使我的想法可行?
尝试更改为此:
/api/res1 controllers.GenericController.index(clazz: Class[_] = classOf[full.package.name.Res1])
对我来说效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.