Parsing query strings on Android

前端 未结 25 1360
时光说笑
时光说笑 2020-11-22 17:41

Java EE has ServletRequest.getParameterValues().

On non-EE platforms, URL.getQuery() simply returns a string.

What\'s the normal way to properly parse the qu

25条回答
  •  被撕碎了的回忆
    2020-11-22 17:49

    If you're using Spring 3.1 or greater (yikes, was hoping that support went back further), you can use the UriComponents and UriComponentsBuilder:

    UriComponents components = UriComponentsBuilder.fromUri(uri).build();
    List myParam = components.getQueryParams().get("myParam");
    

    components.getQueryParams() returns a MultiValueMap

    Here's some more documentation.

提交回复
热议问题