2012-11-29 102 views
6

在我的控制器我有一個刪除方法:在路由中傳遞參數值?

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) 

(有趣的部分是根據傳遞給Delete方法的第二個參數在URI)

然而,這使我有以下錯誤:

identifier expected but 'false' found. 

我在做什麼錯?

回答

16

正確的語法是:

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) 
+0

真棒,工作:-)謝謝! –

+1

/item /:id/delete?confirmed = true。哪個動作會被調用? –

+0

第一個@ andrey.ladniy – Gus