I'm adding generic extension to my Scala 2.11.6, Play 2.3.8 based project, based on Request.queryString
/**
* The parsed query string.
*/
def queryString: Map[String, Seq[String]]
Lets say I have ?param=A¶m=B
. The order in which query returns A & B affects the result, of calculations.
Does play guarantee order of A & B?
In other words do I need to handle order of query parameters explicitly, or it's part of the system contract.
Does play guarantee order of A & B?
I don't think there is an explicit guarantee regarding the order of the params in Play (in general).
In the version I'm using now (Play 2.3.8), Play seems to use Netty's QueryStringDecoder and it indeed keeps the order of the values.
So with something like /some/path?param=1¶m=7¶m=4
, queryString()
will return
"param" -> ["1", "7", "4"]
but no one can assure you this will not change in the future (either in Netty or if Play decides to use something else).
If you are really just targeting 2.3.8, then I think you can safely assume the order is kept. If you want to use other Play versions, then you may want to use explicitly the version of Netty QueryStringDecoder
used by 2.3.8:
QueryStringDecoder qs = new QueryStringDecoder("/a?param=1¶m=7¶m=4");
Map<String, List<String>> queryString = qs.getParameters();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다