jquery如何把数组变为字符串传到服务端并处理

(编辑:jimmy 日期: 2026/4/30 浏览:2)

jquery把数组变为字符串然后在传到服务端(jquery把数组转换成字符串后,格式如1,2,3,速度,rewr) 复制代码 代码如下:
define(function(require, exports, module) {

var Notify = require('common/bootstrap-notify');

module.exports = function($element) {

$element.on('click', '[data-role=batch-delete]', function() {

var $btn = $(this);
name = $btn.data('name');

var ids = [];
$element.find('[data-role=batch-item]:checked').each(function(){
ids.push(this.value);
});

if (ids.length == 0) {
Notify.danger('未选中任何' + name);
return ;
}

if (!confirm('这的要删除选中的' + ids.length + '条' + name + '吗?')) {
return ;
}

$element.find('.btn').addClass('disabled');

Notify.info('正在删除' + name + ',请稍等。', 60);
var values=ids.toString();
$.post($btn.data('url'), {ids:values}, function(){
window.location.reload();
});

});

};

});

接收jquery传过来的字符串,并解析成数组,再把数组转换成list集合
复制代码 代码如下:
/**
* 批量删除私信。
*/
@RequestMapping(value = "/delete", method = {RequestMethod.GET,RequestMethod.POST})
public ResponseEntity<AjaxPostResponse> delete(HttpServletRequest request) {
// 待删除的私信ID列表
String messageIds = ServletRequestUtils.getStringParameter(request, "ids", "");
String[] messageList=messageIds.toString().split(",");
List<String> messageIdList = Arrays.asList(messageList);//数组转换成list
logger.info("------------"+messageIds);
logger.info("------------"+messageList[0]);
try {
boolean opStatus = messageManager.delete(messageIdList);
logger.info("删除私信:opStatus={}", opStatus);
return this.okResponse(opStatus);
} catch (Exception e) {
logger.error("添加私信时发生异常, Cause: ", e);
return this.errorResponse(e.getMessage());
}
}
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。