天天看点

ajax传字符串到后台转为字符串数组

页面ajax方法

//批量退订
	function senUserUnsub_batchUnsubAll() {
		var rows = $('#admin_senUserUnsub_datagrid').datagrid('getChecked');
		var mds = [];
		var spids = [];
		//alert(rows[0].srcMdn);
		if (rows.length > 0) {
			var info = "";
			for ( var i = 0; i < rows.length; i++) {
				info = info+"["+rows[i].srcMdn+"-"+rows[i].spid+"]<br/>";
			} 		
			
			$.messager.confirm('确认', '您确认要批量退订<br/>'+info, function(r) {
				if (r) {
					for ( var i = 0; i < rows.length; i++) {
						mds.push(rows[i].srcMdn+"-"+rows[i].spid);
						//spids.push(rows[i].spid);
					}
					$.ajax({
						url : '${pageContext.request.contextPath}/senUserUnsubController/batchUnsubAll.action',
						data : {
							mdnList:mds.join(','),
							//spidList:spids.join(',')
						},
						dataType : 'json',
						success : function(result) {
							if (result.success) {
								$('#admin_senUserUnsub_datagrid').datagrid('load');
								$('#admin_senUserUnsub_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
							}
							$.messager.show({
								title : '提示',
								msg : result.msg
							});
						}
					});
				}
			});
		} else {
			$.messager.show({
				title : '提示',
				msg : '请勾选要退订的记录!'
			});
		}
		
		
	}	
           

后台转换为字符串数组并且循环取值

String a = "8618523825157-10655599,8615523653371-10655599,8615688241578-106554009810046";
		String[] mdnListArr = a.split(",");
		for(int i=0;i<mdnListArr.length;i++){
			System.out.println(mdnListArr[i]);
		}