2015-07-28 48 views
4

在我build.sbt我有UUID路徑可綁定 - 玩框架

routesImport += "play.api.mvc.PathBindable.bindableUUID" 

而在我的路線,我有:

GET  /groups/:id  controllers.GroupController.get(id) 

而且在我的控制器我有

class GroupController { .... 

    def get (id: UUID) 

我得到以上路線的以下錯誤

type mismatch; 
found : String 
required: java.util.UUID 

如何在Play中使用uuid路徑中的路徑文件。我正在使用play 2.4.2 - scala 2.11.7

回答

10

字符串是路由文件中參數的默認類型。要改變這一點,你需要明確指定一個類型爲ID:

GET  /groups/:id  controllers.GroupController.get(id: java.util.UUID) 

如果你這樣做,你會發現,你也可以刪除的bindableUUID進口在生成文件中。