///<summary>
///将查询字符串解析转换为泛型List的名值集合.
///</summary>
///<param name="queryString">查询字符串的值</param>
///<returns>结果</returns>
public static List<NameValueCollection> GetMultipleRecords(string records)
{
List<NameValueCollection> result = new List<NameValueCollection>();
if (string.IsNullOrEmpty(records))
{
return result;
}

string[] items = records.Split('|');
if (items == null || items.Length == 0)
{
return result;
}

foreach (string item in items)
{
NameValueCollection current = GetQueryString(item);
if (current.Count == 0)
{
continue;
}

result.Add(current);
}

return result;
}

///<summary>
///将查询字符串解析转换为名值集合.
///</summary>
///<param name="queryString">查询字符串的值</param>
///<returns>结果</returns>
public static NameValueCollection GetQueryString(string queryString)
{
NameValueCollection result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
if (string.IsNullOrEmpty(queryString))
{
return result;
}

string key = string.Empty;
string value = string.Empty;
string[] items = queryString.Split('&');
foreach (string item in items)
{
if (!string.IsNullOrEmpty(item))
{
string[] fields = item.Split('=');
if (fields != null && fields.Length == 2)
{
key = fields[0].Trim();
value = fields[1].Trim();

if (string.IsNullOrEmpty(key))
{
continue;
}

result[key] = value;
}
}
}

return result;
}

将查询字符串解析转换为泛型List的名值集合.的更多相关文章

  1. parse_str() 函数把查询字符串解析到变量中。

    定义和用法 parse_str() 函数把查询字符串解析到变量中. 注释:如果未设置 array 参数,则由该函数设置的变量将覆盖已存在的同名变量. 注释:php.ini 文件中的 magic_quo ...

  2. 此请求的查询字符串的长度超过配置的 maxQueryStringLength 值

    异常详细信息: System.Web.HttpException: 此请求的查询字符串的长度超过配置的maxQueryStringLength 值. 我碰到此问题出现的原因是重写了HttpModule ...

  3. parse_str() 函数把查询字符串解析到变量中。

    注释:如果未设置 array 参数,则由该函数设置的变量将覆盖已存在的同名变量. 注释:php.ini 文件中的 magic_quotes_gpc 设置影响该函数的输出.如果已启用,那么在 parse ...

  4. location查询字符串解析

    function getQueryStringArgs() { //取得查询字符串并去掉开头的问号 var qs = (location.search.length >0? location.s ...

  5. 此请求的查询字符串的长度超过配置的 maxQueryStringLength 值 --不仅wen.fonfig一个地方需要设置

    提示已经很明确了... 搜出来的都是: <system.webServer> <security> <requestFiltering> <requestLi ...

  6. 解析URL查询字符串参数为对象以及老浏览器的getElementsByClassName

    高程3使用拼接字符串形式解析的查询字符串,网上有各种正则方式解析的,记得太多,临时需要写的时候,自己都搞混乱了.只记一种吧,用正则. function getQueryStringArgs() { v ...

  7. php的URL查询字符串解析函数

    URL查询字符串格式:Data[650][BLN]=40002307312&Data[650][Status]=電聯無人接聽. 解析这种数据使用函数:parse_str(). parse_st ...

  8. querystring 解析url 查询字符串

    对前端同学来说,经常要碰到一种比较麻烦的情况,那就是url查询字符串的解析问题.说起来也不难,就是比较麻烦. 具体来处理这种情况的时候,相信有一部分同学就是针对具体项目中的需要的字符去正则匹配一下,业 ...

  9. 《JS高级程序设计》笔记 —— 解析查询字符串

    今天在继续翻阅<JS高级程序设计>的时候,正好翻到location对象这一小节,其中有一部分就是讲的解析查询字符串.看到这个内容立马想到了做去哪儿秋招笔试题的时候有这么一道题. 去哪儿笔试 ...

随机推荐

  1. UIBarButtonItem-添加自定义Left或者Right按钮

    为UINavigationController添加UINavigationItem,我们可以这样写:   1.添加返回导航按钮backBarButtonItem   1.用系统自带的返回按钮 UIBa ...

  2. python之对指定目录文件夹的批量重命名

    python之对指定目录文件夹的批量重命名 import os,shutil,string dir = "/Users/lee0oo0/Documents/python/test" ...

  3. go语言实现一个简单的登录注册web小程序

    最近学习golang也有一段时间了,基础差不多学了个大概,因为本人是java程序员,所以对web更感兴趣.根据<go web编程>中的例子改编一个更简单的例子,供新手参考,废话不多说,上菜 ...

  4. android studio logcat 换行(日志换行)

    起因 今天突然要调试网络数据,调试一大截那个xml数据. 解决思路 一开始去setting哪里看一下logcat 是否有line break,类似的字眼,可惜没有. 我猜如果没有在设置的话,估计就在“ ...

  5. mac上parallel与virtualbox无法共存

    Mac reboots when you attempt to launch Parallels Desktop 8 and Virtual Box simultaneously Article ID ...

  6. BCB6 重装后的项目编译莫名问题

    我很少用 bcb ,重装 bcb6 后原来的项目居然不能编译成功了,看了一下是控件的问题,但很多控件实际上并不关联的,而 bcb 坚持要你"拥有"当时的控件环境,折腾很久实在是没发 ...

  7. GPS accuracy in Android

    Get the estimated accuracy of this location, in meters. We define accuracy as the radius of 68% conf ...

  8. [Javascript] The "this" keyword

    The very first thing to understand when we're talking about this-keyword is really understand what's ...

  9. cordova混合开发:Android中native调用javascript

    今天学习怎么在java中调用javascript方法,做个记录: 第一种方式,这个最简单: loadUrl("javascript:func1()"); 要注意要在devicere ...

  10. 国内 Composer 镜像收集

    本文转载自: https://www.insp.top/article/composer-mirror-image 常见的: { "repositories": [ {" ...