jquery converts the array into a string and then transmits it to the server (after jquery converts the array into a string, the format is such as 1, 2, 3, speed, 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('No' name is selected);
return;
}
if (!confirm('The selected 'ids.length' should be deleted ' name '? ')) {
return ;
}
$element.find('.btn').addClass('disabled');
Notify .info('Deleting ' name ', please wait.', 60);
var values=ids.toString();
$.post($btn.data('url'), {ids :values}, function(){
window.location.reload();
});
});
};
}) ;
Receive the string passed by jquery, parse it into an array, and then convert the array into a list collection
/**
* Delete private messages in batches.
*/
@RequestMapping(value = "/delete", method = {RequestMethod.GET,RequestMethod.POST} )
public ResponseEntity
delete(HttpServletRequest request) {
// List of private message IDs to be deleted
String messageIds = ServletRequestUtils.getStringParameter(request, "ids", "");
String [] messageList=messageIds.toString().split(",");
List messageIdList = Arrays.asList(messageList);//The array is converted into a list
logger.info("--- ---------" messageIds);
logger.info("------------" messageList[0]);
try {
boolean opStatus = messageManager.delete(messageIdList);
logger.info("Delete private message: opStatus={}", opStatus);
return this.okResponse(opStatus);
} catch (Exception e) {
logger.error("An exception occurred while adding a private message, Cause: ", e);
return this.errorResponse(e.getMessage());
}
}