8

在我的控制器中,我有一个删除方法:

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. 

我究竟做错了什么?

4

1 回答 1

19

正确的语法是:

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)
于 2012-11-29T19:46:28.093 回答