jquery transforms the array into a string and then spreads it to the server (jquery converts the array to a string, formatted like 1,2,3, speed, REWR)
Copy Code code as follows:
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 (' No ' + name selected ');
return;
}
if (!confirm (') would you like to remove the selected ' + ids.length + ' bar ' + name + ')? ')) {
return;
}
$element. Find ('. btn '). addclass (' disabled ');
Notify.info (' deleting ' + name + '), please wait a moment. ', 60);
var values=ids.tostring ();
$.post ($btn. Data (' URL '), {ids:values}, function () {
Window.location.reload ();
});
});
};
});
Receive a string from jquery, parse the array, and then convert it to the list collection
Copy Code code as follows:
/**
* Bulk Delete DMS.
/*
@RequestMapping (value = "/delete", method = {Requestmethod.get,requestmethod.post})
Public responseenti ty<ajaxpostresponse> Delete (HttpServletRequest request) {
///DMS ID list to be deleted
String messageids = Servletreque Stutils.getstringparameter (Request, "IDs", "");
String[] messagelist=messageids.tostring (). Split (",");
List<string> messageidlist = arrays.aslist (messagelist);//array converted to List
Logger.info ("------------" + Messageids);
Logger.info ("------------" +messagelist[0]);
try {
Boolean opstatus = Messagemanager.delete (messageidlist);
Logger.info ("Delete dms: opstatus={}", Opstatus);
return This.okresponse (opstatus);
} catch (Exception e) {
Logger.error ("exception occurred while adding DMS, Cause:", e);
Return This.errorresponse (E.getmessage ());
}
}