1

Can you tell Play Framework to call an exact URL without messing around with the URL?

I want to do a GET Request with empty values.

However while inspecting the request done by Play, even though I have hand written an exact URL the Play Framework destroys my URL and make one up by itself.

An example would be something like:

  • My handwritten request:   http://address/?id=&filter=
  • Play frameworks request: http://address/?id&filter

I'm well familiar with that the equals sign is optional for empty values but this is of no interest when the endpoint exposing the rest API don't.

4

2 回答 2

1

这与您的问题没有直接关系,但我遇到了这个谷歌线程,它解释了如何调用具有多个参数的方法......

其他情况:

GET     /nice-test/:id/:name   controllers.Application.test(id:Long,
name:String) will match /nice-test/10/james

GET     /ugly-test             controllers.Application.test(id:Long ?=
0, name:String ?= "") will match /ugly-test?id=10&name=james

它们都将被正确传递给同一个动作,但丑陋的情况只是......丑陋:

public static Result test(Long id, String name){
    return ok("The "+name+" has id "+id);
}

在您看来,您还应该以相同的方式为这两种情况构建 url:

<a href="@routes.Application.delete(user.id, user.name)">Show me user</a>

当我尝试 Play 时,我会在这里写更多;我希望这引发了一些想法。

于 2013-06-24T02:23:57.677 回答
0

将空字符串设置为值应该可以为您解决问题:

 http://address/?id=""&filter=""
于 2013-06-23T12:43:40.810 回答