嗨,我是 Grails 的新手,我已经实现了删除收件箱中的消息的删除操作,但现在我想更改 flash 消息以显示“2 条消息已删除”而不是“消息 4 已删除,消息 5 已删除”,如果删除多条消息。请协助,以下是我的删除操作
定义删除(){
def messageInstance = Message.get(params.id)
// render error if no message found
if (!messageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: 'message.label', default: 'Message'), params.id])
redirect(action: "phone")
} else {
// get the device that we are deleting from
//specify phoneNumber so as to delete the device by phoneNumber
def device = MessagingDevice.findByPhoneNumber(params.phoneNumber)
// invoke deleteFromDevice on domain object, which returns true if successful
if (messageInstance.deleteFromDevice(device)) {
flash.message = message(code: 'default.deleted.message', args: [message(code: 'message.label', default: 'Message'), params.id])
redirect(action: "phone", params:[phoneNumber:params.phoneNumber])
}
}
}