Routes with optional parameter - Play 2.1 Scala

前端 未结 5 927
旧巷少年郎
旧巷少年郎 2020-12-10 03:20

So in Play 2.0 I had this:

GET     /tasks/add              controllers.Tasks.addTask(parentId: Option[Long] = None)
GET     /tasks/:parentId/add    controlle         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-10 04:06

    I had the same thing and more if you specify the pass as GET/foo:id and controllers.Application.foo(id : Option[Long] ?= None) you get an error It is not allowed to specify a fixed or default value for parameter: 'id' extracted from the path on the other side you can do as follows GET/foo controllers.Application.foo(id : Option[Long] ?= None) and it will work expecting that your request looks like as .../foo?id=1

提交回复
热议问题