assign null default value for optional query param in route - Play Framework

前端 未结 2 1975
情深已故
情深已故 2021-01-04 12:53

I\'m trying to define an optional query parameter that will map to a Long, but will be null when it is not present in the URL:

GET          


        
2条回答
  •  暖寄归人
    2021-01-04 13:24

    In my case I use a String variable.

    Example :

    In my route :

    GET /foo controller.Foo.index(id: String ?= "")

    Then I convert in my code with a parser to Long --> Long.parseLong.

    But I agree that the method of Hristo is the best.

提交回复
热议问题