Play framework 2: Use Array[String] in route

后端 未结 4 685
忘了有多久
忘了有多久 2021-02-05 13:56

I want to generate an url like this:

/photo?tags=tag1,tag2,tag3

routes file:

GET     /photo  controllers.Photos.list         


        
4条回答
  •  别跟我提以往
    2021-02-05 14:02

    I think that you should use a common String and then take care about converting it to an Array in your controller

    routes:

    GET     /photo  controllers.Photos.list(tags:String ?= "")
    

    in Java:

    public static Result list (String tags){
        String[] tagsArray = tags.split(",");
        // do something with tagsArray
        return ok();
    }
    

提交回复
热议问题