Parsing query strings on Android

前端 未结 25 1093
时光说笑
时光说笑 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:58

    Based on the answer from BalusC, i wrote some example-Java-Code:

        if (queryString != null)
        {
            final String[] arrParameters = queryString.split("&");
            for (final String tempParameterString : arrParameters)
            {
                final String[] arrTempParameter = tempParameterString.split("=");
                if (arrTempParameter.length >= 2)
                {
                    final String parameterKey = arrTempParameter[0];
                    final String parameterValue = arrTempParameter[1];
                    //do something with the parameters
                }
            }
        }
    

提交回复
热议问题