`
woshixushigang
  • 浏览: 562360 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

string[] to map

    博客分类:
  • j2ee
 
阅读更多

 

 

public static Map<Integer, Object> convertStringToMap(String[] value) {
		if (value == null) {
			return new HashMap<Integer, Object>();
		}
		Map<Integer, Object> ret = new HashMap<Integer, Object>();
		for (int i = 0; i < value.length; i++) {
			int key = getIntValue(value[i]);
			ret.put(key, key);
		}
		return ret;
	}
 

 

Map<Integer, Object> sendto = AppUtils.convertStringToMap(this.request.get().getParameterValues("sendto"));
			if(sendto.get(0)!=null)
			{
				System.out.println("0");
			}
			if(sendto.get(1)!=null)
			{
				System.out.println("1");
				
			}

 小问题还真容易忽略,如果你sendto.get("1")就不行了。

分享到:
评论

相关推荐

    StringtoList和StringtoMap和StringtoObject和StringtoArray

    Json格式的字符串转成List、Array、Map、Object、List等,就是各种字符串转其他格式的方法.有个封装好的转换方法和一个我自己做的示例

    string-map.js:简单的 javascript StringMap 类

    script src =" path/to/string-map.js " &gt; &lt;/ script &gt; ###用法 // nodejs// var StringMap = require('string-map');var map = new StringMap ( ) ;map . set ( 'one' , 1 ) ;map . set ( 'two' , 2 )...

    Golang的 Json string和Map互相转换

    在存储的时候想把数据列表存储成json string,但是在代码使用的时候又觉得用map更快更方便。这个时候就需要相互转换,下面是一个转换的例子。... // test json string to map m, err := JsonToMap(jsonStr) if err !=

    list转String

    String list 转化为 String, 使用Stringbuffer 。。。。。。。。。。。。。。。

    map.toString()后转换成Map类型

    map.toString()后转换成Map类型

    json字符串转成 Map/List

    NULL 博文链接:https://wuniu2010.iteye.com/blog/1771934

    xml2map:XML到MAP转换器的Golang编写

    类似于map [string] interface {}或map [interface {}] interface {}。 这是从旧的XML格式到map [string] interface {} Golang的转换器 例如,map [string] interface {}可以用作模板生成中的通用类型。 Golang...

    Java中 List《map》把里面map中某个key相同记录的其他key 的 value 合并

    Java中 List《map》把里面map中某个key相同记录的其他key 的 value 合并 Java中 List《map》把里面map中某个key相同记录的其他key 的 value 合并

    将JSON字符串转换成Map对象的方法

    public Map&lt;String&gt; toMap(Object object) { Map&lt;String&gt; data = new HashMap&lt;String&gt;(); // 将json字符串转换成jsonObject JSONObject jsonObject = JSONObject.fromObject(object); Iterator ite = jsonObject...

    golang映射Map的方法步骤

    map是key-value数据结构,又称为字段或者关联数组...var a map[string]string a = make(map[string]string, 10) a["n1"] = "a" a["n2"] = "b" a["n3"] = "c" 二、使用方式 先声明,再make var a map[string]string a

    前端开源库-textlint-util-to-string

    前端开源库-textlint-util-to-stringtextlin util to string,textlin util使用sourcemap将段落节点转换为文本。

    Java实现HTML文件转PDF文件

    Map&lt;String, String&gt; map = json2Map(); 3、通过JSoup 解析HMTL内容,并动态给HMTL标签内容赋值 //解析HMTL文件并给字符串赋值 urlsource = parseHtml(urlsource, map); 4、把设置发了的HTML文件转化成PDF文件 ...

    configmap-reload:简单的二进制文件在Kubernetes ConfigMap更新时触发重新加载

    Kubernetes ConfigMap重新加载 configmap-reload是一个简单的二进制文件,... the config map volume directory to watch for updates; may be used multiple times -web.listen-address string address to liste

    全量断言方法-Java版

    全量断言方法-Java版 /** * 校验结果的每一个值 * * @param exp ... Map&lt;String, Object&gt; expDataInfo = JsonUtils.objectToMap(m.getValue());//期望结果 .......................................

    josn包,josn工具类

    static String map2Json(Map&lt;String, Object&gt; map) { if (map.isEmpty()) return "{}"; StringBuilder sb = new StringBuilder(map.size() ); sb.append('{'); Set&lt;String&gt; keys = map.keySet(); for ...

    jdk1.8.0_202.zip

    java 开发者 配置jdk1.8 一下是jdk1.8的新特性Lamdbd表达式 forEach循环遍历 List&lt;String&gt; names = new ArrayList();... List&lt;Integer&gt; c = names.stream.map(String::length).collect(Collectors.toList());

    开发中复杂Json解析(LinkedTreeMap)

    1,先将接口返回的JSON,用gson.tojson(map)方法,将LinkedTreeMap对象转成String。 2,再通过gson.fromjson(string,type)方法,将String转成LinkedTreeMap。用到了Type type=new TypeToken(){}.getType; 3,再将...

    android 百度地图 定位示例

    this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_map_api_demo, menu); return true; } /** * 初始化方法 */ private void init() { //mMapView = ...

    基于spring boot 日志(logback)报错的解决方式

    No converter found capable of converting from type [java.lang.String] to type [java.util.Map] org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '...

    hive中将string数据转为bigint的操作

    参考:Hive – Converting a string to bigint 补充知识:hive中bigint和varchar字段做关联,关联数据错误的解决方法 把bigint和varchar都隐式转换成String类型的就可以关联出正确的结果了 cast(t1.PARTY_NUM as ...

Global site tag (gtag.js) - Google Analytics