在我的控制器中,我有一个删除方法:
delete(String id, boolean confirmed)
现在在路由中我想相应地映射两个URI:
GET /item/:id/delete controllers.Application.delete(id:String, false)
GET /item/:id/delete/confirmed controllers.Application.delete(id:String, true)
(有趣的部分是根据URI传递给delete方法的第二个参数)
然而,这给了我以下错误:
identifier expected but 'false' found.
我做错了什么?
答案 0 :(得分:18)
正确的语法是:
GET /item/:id/delete controllers.Application.delete(id:String, confirmed:Boolean ?= false)
GET /item/:id/delete/confirmed controllers.Application.delete(id:String, confirmed:Boolean ?= true)