当前位置: 首页 > news >正文

【.net core】yisha框架imageupload组件多图上传修改

 框架\wwwroot\lib\imageupload\1.0\js路径下imgup.js文件,参照旧版本代码和修改代码修改


(function ($) {"use strict";var deleteParent;var deleteDisplay = 'none';var defaults = {fileType: ["jpg", "png", "bmp", "jpeg", "gif"],   // 上传文件的类型fileSize: 1024 * 1024 * 200                 // 上传文件的大小 10M};$.fn.imageUpload = function (option, param) {if (typeof option == 'string') {return $.fn.imageUpload.methods[option](this, param);}var _option = $.extend({}, $.fn.imageUpload.defaults, option || {});var target = $(this);var id = target.attr("id");var inputFileId = id + "_file";var html = '';html += '<section class="img-section">';html += '    <div class="z_photo upimg-div clear">';html += '       <section class="z_file fl">';if (_option.canAdd == 1) {html += '           <img src="' + _option.context + 'lib/imageupload/1.0/img/add.png" class="add-img">';deleteDisplay = 'block';}/*** 旧版本代码*///html += '           <input type="file" name="' + inputFileId + '" id="' + inputFileId//    + '" class="file-image" callback="' + _option.uploadImage + '" context="'//    + _option.context + '" limit="' + _option.limit//    + '"  value="" accept="image/jpg,image/jpeg,image/png,image/bmp" />';/*** 20231024修改* 为input元素增加multiple属性*/html += '           <input type="file" name="' + inputFileId + '" id="' + inputFileId+ '" class="file-image" callback="' + _option.uploadImage + '" context="'+ _option.context + '" multiple limit="' + _option.limit+ '"  value="" accept="image/jpg,image/jpeg,image/png,image/bmp" />';html += '       </section>';html += '   </div>';html += '</section>';html += '<aside class="mask works-mask">';html += '   <div class="mask-content">';html += '       <div class="del-p">您确定要删除图片吗?</div>';html += '       <div class="check-p"><span class="del-com wsdel-ok">确定</span><span class="wsdel-no">取消</span></div>';html += '   </div>';html += '</aside>';target.append(html);target.find(".wsdel-ok").click(function () {$(".works-mask").hide();var numUp = deleteParent.siblings().length;if (numUp < 6) {deleteParent.parent().find(".z_file").show();}deleteParent.remove();});target.find(".wsdel-no").click(function () {$(".works-mask").hide();});$("#" + inputFileId).change(function () {prepareUploadImage(inputFileId);});};$.fn.imageUpload.defaults = {uploadImage: '',    // 上传图片回调limit: 10,          // 上传限制context: '',        // 当前页面根目录canPreview: 1,      // 是否可以预览(0不可以,1可以)canAdd: 1           // 是否可以添加(0不可以,1可以)};$.fn.imageUpload.methods = {getImageUrl: function (target) {var imageUrl = '';var list = $(target).find('.up-section').find('.up-img');for (var i = 0; i < list.length; i++) {if (i == 0) {imageUrl += $(list[i]).attr("src");} else {imageUrl += ';';imageUrl += $(list[i]).attr("src");}}return imageUrl;},setImageUrl: function (target, imageUrl) {if (imageUrl) {var id = $(target).attr("id");var inputFileId = id + "_file";var context = $("#" + inputFileId).attr("context");var urlArr = imageUrl.split(';');for (var i = 0; i < urlArr.length; i++) {if (urlArr[i] != "") {var deleteId = ys.getGuid();var imageName = urlArr[i].substring(urlArr[i].lastIndexOf('/') + 1);var html = '';html += '<section class="up-section fl">';html += '   <span class="up-span"></span>';html += '   <img id="' + deleteId + '" class="close-upimg" style="display:' + deleteDisplay + '" src="' + context + 'lib/imageupload/1.0/img/delete.png" />';if (urlArr[i].indexOf('http') > -1) {html += '   <img class="up-img" src="' + urlArr[i] + '" />';}else {html += '   <img class="up-img" src="' + context + ys.trimStart(urlArr[i], '/') + '" />';}html += '   <p class="img-name-p">"' + imageName + '"</p>';html += '</section>';$(html).insertBefore($(target).find(".z_file"));$("#" + deleteId).on("click", function () {$("#" + inputFileId).imageUpload("deleteImage", deleteId)});}}$(".up-span").Huipreview();$("#" + inputFileId).imageUpload("checkImageLimit")}},deleteImage: function (target, deleteId) {var _target = $(target);var inputFileId = _target.attr("id");if (!!event) {event.preventDefault();event.stopPropagation();}$(".works-mask").show();deleteParent = $("#" + deleteId).parent();$("#" + inputFileId).imageUpload("checkImageLimit");},checkImageLimit: function (target) {var _target = $(target);var num = _target.parents(".z_photo").find(".up-section").length;var limit = _target.attr("limit");if (num >= limit) {_target.parent().hide();} else {_target.parent().show();}}};function prepareUploadImage(inputFileId) {var target = $("#" + inputFileId);var callback = target.attr("callback");var limit = target.attr("limit");if (!callback || callback == '') {alert("请提供上传方法");return;}var inputFile = document.getElementById(inputFileId);var imgContainer = target.parents(".z_photo"); //存放图片的父亲元素var fileList = inputFile.files; //获取的图片文件//遍历得到的图片文件var num = imgContainer.find(".up-section").length;var totalNum = num + fileList.length;  //总的数量if (fileList.length > limit || totalNum > limit) {alert("上传图片数目不可以超过" + limit + "个,请重新选择");  //一次选择上传超过5个 或者是已经上传和这次上传的到的总数也不可以超过5个}else if (num < limit) {validateUpload(fileList);var uploadSuccess = function (imgPath) {/*** 旧版本代码*///var section = $("<section class='up-section fl loading'>");//imgContainer.prepend(section);//var span = $("<span class='up-span'>");//span.appendTo(section);//var context = $("#" + inputFileId).attr("context");//var deleteId = ys.getGuid();//var deleteImg = $("<img id='" + deleteId + "' class='close-upimg'> style='display:" + deleteDisplay + "'").on("click", function () {//    $("#" + inputFileId).imageUpload("deleteImage", deleteId)//});//deleteImg.attr("src", context + "lib/imageupload/1.0/img/delete.png").appendTo(section);//var realImg = $("<img class='up-img up-opcity'>");//realImg.attr("src", imgPath);//realImg.appendTo(section);//var p = $("<p class='img-name-p'>");//p.html(imgPath.substring(imgPath.lastIndexOf('/') + 1)).appendTo(section);/*** 20231024修改* 增加方法多文件上传功能*/ if (typeof (imgPath) == 'string') {var section = $("<section class='up-section fl loading'>");imgContainer.prepend(section);var span = $("<span class='up-span'>");span.appendTo(section);var context = $("#" + inputFileId).attr("context");var deleteId = ys.getGuid();var deleteImg = $("<img id='" + deleteId + "' class='close-upimg'> style='display:" + deleteDisplay + "'").on("click", function () {$("#" + inputFileId).imageUpload("deleteImage", deleteId)});deleteImg.attr("src", context + "lib/imageupload/1.0/img/delete.png").appendTo(section);var realImg = $("<img class='up-img up-opcity'>");realImg.attr("src", imgPath);realImg.appendTo(section);var p = $("<p class='img-name-p'>");p.html(imgPath.substring(imgPath.lastIndexOf('/') + 1)).appendTo(section);}else {imgPath.forEach(function (item) {var section = $("<section class='up-section fl loading'>");imgContainer.prepend(section);var span = $("<span class='up-span'>");span.appendTo(section);var context = $("#" + inputFileId).attr("context");var deleteId = ys.getGuid();var deleteImg = $("<img id='" + deleteId + "' class='close-upimg'> style='display:" + deleteDisplay + "'").on("click", function () {$("#" + inputFileId).imageUpload("deleteImage", deleteId)});deleteImg.attr("src", context + "lib/imageupload/1.0/img/delete.png").appendTo(section);var realImg = $("<img class='up-img up-opcity'>");realImg.attr("src", item);realImg.appendTo(section);var p = $("<p class='img-name-p'>");p.html(item.substring(item.lastIndexOf('/') + 1)).appendTo(section);})}setTimeout(function () {$(".up-section").removeClass("loading");$(".up-img").removeClass("up-opcity");}, 450);$("#" + inputFileId).imageUpload("checkImageLimit");};/*** 旧版本代码*///var currentFile = fileList[fileList.length - 1];//只返回最后一个文件内容//doCallback(eval(callback), [currentFile, uploadSuccess]);/*** 20231024修改* 将所有的上传内容返回自定义方法*/doCallback(eval(callback), [fileList, uploadSuccess]);}}function validateUpload(files) {var arrFiles = [];//替换的文件数组for (var i = 0, file; file = files[i]; i++) {//获取文件上传的后缀名var newStr = file.name.split("").reverse().join("");if (newStr.split(".")[0] != null) {var type = newStr.split(".")[0].split("").reverse().join("");console.log(type + "===type===");if (jQuery.inArray(type, defaults.fileType) > -1) {// 类型符合,可以上传if (file.size >= defaults.fileSize) {alert(file.size);alert('您这个"' + file.name + '"文件大小过大');} else {// 在这里需要判断当前所有文件中arrFiles.push(file);}} else {alert('您这个"' + file.name + '"上传类型不符合');}} else {alert('您这个"' + file.name + '"没有类型, 无法识别');}}return arrFiles;}// 动态调用方法,并传递参数function doCallback(fn, args) {fn.apply(this, args);}
})(jQuery);

 页面代码,替换原有页面初始化和自定义上传触发方法

//初始化组件方法
$("#thumbImage").imageUpload({ uploadImage: 'uploadThumbImage', limit: 10, context: ctx });//limit参数,设置单次上传和总上传数量function uploadThumbImage(file, callback) {//自定义的上传触发方法var formdata = new FormData();//formdata.append("fileList", file);//file为单文件数据(File类型)console.log('uploadThumbImage', file)for (var i = 0; i < file.length; i++) {//file为多文件数据(FileList类型)formdata.append("fileList", file[i]);//手动给formdata中添加文件流内容}ys.ajaxUploadFile({//url: '@GlobalContext.SystemConfig.ApiSite' + '/File/UploadFile?fileModule=@UploadFileType.News.ParseToInt()',url: '@Url.Content("~/File/uploadImagesProc")' + "?fileModule=@UploadFileType.News.ParseToInt()",data: formdata,success: function (obj) {if (obj.Tag == 1) {if (callback) {//callback('@GlobalContext.SystemConfig.ApiSite' + obj.Data);callback(obj.Data);}}else {ys.msgError(obj.Message);}}})}

后台代码,可直接复制,UploadFileProc方法需在FileHelper类中创建

 /// <summary>/// 单/多文件上传/// </summary>/// <param name="files"></param>/// <returns></returns>[HttpPost]public async Task<TData<object>> uploadImagesProc(int fileModule, IFormFileCollection fileList){TData<object> obj = new TData<object>();obj = await FileHelper.UploadFileProc(fileModule, fileList);return obj;}
#region 上传多个文件/// <summary>/// 上传多个文件/// </summary>/// <param name="fileModule"></param>/// <param name="files">文件流集合</param>/// <returns></returns>public async static Task<TData<object>> UploadFileProc(int fileModule, IFormFileCollection files){string dirModule = string.Empty;TData<object> obj = new TData<object>();if (files == null || files.Count == 0){obj.Message = "请先选择文件!";return obj;}//IFormFile file = files[0];List<object> resultObj = new List<object>();foreach (IFormFile file in files){TData objCheck = null;objCheck = CheckFileExtension(Path.GetExtension(file.FileName), ".jpg|.jpeg|.gif|.png");if (objCheck.Tag != 1){obj.Tag = 0;obj.Message = objCheck.Message;return obj;}switch (fileModule){case (int)UploadFileType.Portrait:objCheck = CheckFileExtension(Path.GetExtension(file.FileName), ".jpg|.jpeg|.gif|.png");if (objCheck.Tag != 1){obj.Message = objCheck.Message;return obj;}dirModule = UploadFileType.Portrait.ToString();break;case (int)UploadFileType.News:if (file.Length > 5 * 1024 * 1024) // 5MB{obj.Message = "文件最大限制为 5MB";return obj;}objCheck = CheckFileExtension(Path.GetExtension(file.FileName), ".jpg|.jpeg|.gif|.png");if (objCheck.Tag != 1){obj.Message = objCheck.Message;return obj;}dirModule = UploadFileType.News.ToString();break;case (int)UploadFileType.Import:objCheck = CheckFileExtension(Path.GetExtension(file.FileName), ".xls|.xlsx");if (objCheck.Tag != 1){obj.Message = objCheck.Message;return obj;}dirModule = UploadFileType.Import.ToString();break;default:obj.Message = "请指定上传到的模块";return obj;}string fileExtension = TextHelper.GetCustomValue(Path.GetExtension(file.FileName), ".png");string newFileName = SecurityHelper.GetGuid() + fileExtension;string dir = "Resource" + Path.DirectorySeparatorChar + dirModule + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd").Replace('-', Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;string absoluteDir = Path.Combine(GlobalContext.HostingEnvironment.ContentRootPath, dir);string absoluteFileName = string.Empty;if (!Directory.Exists(absoluteDir)){Directory.CreateDirectory(absoluteDir);}absoluteFileName = absoluteDir + newFileName;try{using (FileStream fs = System.IO.File.Create(absoluteFileName)){await file.CopyToAsync(fs);fs.Flush();}resultObj.Add(Path.AltDirectorySeparatorChar + ConvertDirectoryToHttp(dir) + newFileName);//obj.Data = ;//obj.Message = Path.GetFileNameWithoutExtension(TextHelper.GetCustomValue(file.FileName, newFileName));//obj.Description = (file.Length / 1024).ToString(); // KB//obj.Tag = 1;}catch (Exception ex){obj.Tag = 0;obj.Message = ex.Message;}}if (resultObj.Count > 0){obj.Tag = 1;obj.Message = "上传成功";obj.Data = resultObj;}return obj;}#endregionpublic static string ConvertDirectoryToHttp(string directory){directory = directory.ParseToString();directory = directory.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);return directory;}public static TData CheckFileExtension(string fileExtension, string allowExtension){TData obj = new TData();string[] allowArr = TextHelper.SplitToArray<string>(allowExtension.ToLower(), '|');if (allowArr.Where(p => p.Trim() == fileExtension.ParseToString().ToLower()).Any()){obj.Tag = 1;}else{obj.Message = "只有文件扩展名是 " + allowExtension + " 的文件才能上传";}return obj;}public class TextHelper{/// <summary>/// 获取默认值/// </summary>/// <param name="value"></param>/// <param name="defaultValue"></param>/// <returns></returns>public static string GetCustomValue(string value, string defaultValue){if (string.IsNullOrEmpty(value)){return defaultValue;}else{return value;}}/// <summary>/// 截取指定长度的字符串/// </summary>/// <param name="value"></param>/// <param name="length"></param>/// <returns></returns>public static string GetSubString(string value, int length, bool ellipsis = false){if (string.IsNullOrEmpty(value)){return value;}if (value.Length > length){value = value.Substring(0, length);if (ellipsis){value += "...";}}return value;}/// <summary>/// 字符串转指定类型数组/// </summary>/// <param name="value"></param>/// <param name="split"></param>/// <returns></returns>public static T[] SplitToArray<T>(string value, char split){T[] arr = value.Split(new string[] { split.ToString() }, StringSplitOptions.RemoveEmptyEntries).CastSuper<T>().ToArray();return arr;}}

 

相关文章:

【.net core】yisha框架imageupload组件多图上传修改

框架\wwwroot\lib\imageupload\1.0\js路径下imgup.js文件&#xff0c;参照旧版本代码和修改代码修改 (function ($) {"use strict";var deleteParent;var deleteDisplay none;var defaults {fileType: ["jpg", "png", "bmp", "…...

vscode markdown 使用技巧 -- 如何快速打出一个Tab 或多个空格

背景描述&#xff1a; 我在使用VSCode&#xff0c;这玩意很好用&#xff0c;但是&#xff0c;有一个缺点是&#xff0c;我想使用Tab来做一些对齐&#xff0c;但是我发现在VSCode中&#xff0c;无论是Tab还是多个空格&#xff0c;最终显示出来的都是一个空格 使用代码可以实现打…...

I/O 模型学习笔记【全面理解BIO/NIO/AIO】

文章目录 I/O 模型什么是 I/O 模型Java支持3种I/O模型BIO&#xff08;Blocking I/O&#xff09;NIO&#xff08;Non-blocking I/O&#xff09;AIO&#xff08;Asynchronous I/O&#xff09; BIO、NIO、AIO适用场景分析 java BIOJava BIO 基本介绍Java BIO 编程流程一个栗子实现…...

【Python学习笔记】字符编码

1. 字符串编码 Python3语言里面的字符串对象是unicode字符串&#xff0c;在内存中实际存储时&#xff0c;使用的是 UTF16 编码。但通常不会将UTF16编码的内容写到磁盘或者在网络进行传输&#xff0c; 因为utf16编码比较浪费空间。特别是如果文字信息基本都是英文符号的情况下&…...

华为昇腾NPU卡 大模型LLM ChatGLM2模型推理使用

参考&#xff1a;https://gitee.com/mindspore/mindformers/blob/dev/docs/model_cards/glm2.md#chatglm2-6b 1、安装环境&#xff1a; 昇腾NPU卡对应英伟达GPU卡&#xff0c;CANN对应CUDA底层&#xff1b; mindspore对应pytorch&#xff1b;mindformers对应transformers 本…...

Git 拉取远程更新报错

报错内容如下&#xff1a; cannot lock ref refs/remotes/origin/bugfix/bug: refs/remotes/origin/bugfix 已存在&#xff0c;无法创建 refs/remotes/origin/bugfix/bug 来自 gitlab.zhangyue-inc.com:dejian_ios/iReaderDejian! [新分支] bugfix/bug -> ori…...

腾讯云国际站服务器端口开放失败怎么办?

腾讯云服务器是腾讯公司推出的一种云服务&#xff0c;用户能够经过这种方式在互联网上进行数据存储和计算。然而&#xff0c;用户在运用腾讯云服务器时或许会遇到各种问题&#xff0c;其间端口敞开失利是一个常见问题。本文将具体介绍如何解决腾讯云服务器端口敞开失利的问题。…...

一句话解释什么是出口IP

出口 IP 是指从本地网络连接到公共互联网时所使用的 IP 地址。这个 IP 地址是由 Internet 服务提供商(ISP)分配给你的,它可以用来标识你的网络流量的来源。如果你使用的是 NAT(网络地址转换)技术,则在 NAT 设备内部会进行地址转换,使得多个设备可以共享同一个公共 IP 地…...

深入理解强化学习——强化学习的历史:试错学习

分类目录&#xff1a;《深入理解强化学习》总目录 让我们现在回到另一条通向现代强化学习领域的主线上&#xff0c;它的核心则是试错学习思想。我们在这里只对要点做概述&#xff0c;《深入理解强化学习》系列后面的文章会更详细地讨论这个主题。根据美国心理学家R.S.woodworth…...

分享一个用HTML、CSS和jQuery构建的漂亮的登录注册界面

作为一个前端开发人员&#xff0c;我们经常需要构建用户的登录和注册界面。一个漂亮、用户友好的登录注册界面对于提升用户体验和网站形象至关重要。以下我们使用HTML、CSS和jQuery来做一个漂亮的登录注册界面。 首先&#xff0c;我们需要创建一个html文档&#xff0c;定义登录…...

Java学习 习题 1.

一、 1.2. 3. 4. 5. 二、 1. 2. 3. 4. 5. 6. 7. 8....

第六节——Vue中的事件

一、定义事件 Vue 元素的事件处理和 DOM 元素的很相似&#xff0c;但是有一点语法上的不同 使用修饰符&#xff08;v-on:的缩写&#xff09;事件名的方式 给dom添加事件后面跟方法名&#xff0c;方法名可以直接加括号如click"add()"里面进行传参。对应的事件处理函…...

设置GridView单选

/// <summary> /// 设置GridView单选 /// </summary> /// <param name"view"></param> /// <param name"selectCaption"></param> public static void SetGridViewSingleSel…...

[Python从零到壹] 七十二.图像识别及经典案例篇之OpenGL入门及绘制基本图形和3D图

十月太忙,还是写一篇吧!祝大家1024节日快乐O(∩_∩)O 欢迎大家来到“Python从零到壹”,在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界。所有文章都将结合案例、代码和作者的经验讲解,真心想把自己近十年的编程经验分享给大家,希…...

论文-分布式-并发控制-Lamport逻辑时钟

目录 前言 逻辑时钟讲解 算法类比为面包店内取号 Lamport算法的时间戳原理 Lamport算法的5个原则 举例说明 算法实现 参考文献 前言 在并发系统中&#xff0c;同步与互斥是实现资源共享的关键Lamport面包店算法作为一种经典的解决并发问题的算法&#xff0c;它的实现原…...

长三角实现区块链电子医疗票据互联互通,蚂蚁链提供技术支持

10月25日&#xff0c;记者从浙江省财政厅发布的消息获悉&#xff0c;上海、浙江、江苏和安徽三省一市基于蚂蚁链实现区块链电子医疗票据互联互通&#xff0c;商业保险理赔作为首个规模化应用场景正式落地&#xff0c;蚂蚁保“安心赔”理赔服务率先接入。 今后&#xff0c;老百…...

Redis快速上手篇(三)(事务+Idea的连接和使用)

Redis事务 可以一次执行多个命令&#xff0c;本质是一组命令的集合。一个事务中的 所有命令都会序列化&#xff0c;按顺序地串行化执行而不会被其它命令插入&#xff0c;不许加塞。 单独的隔离的操作 官网说明 https://redis.io/docs/interact/transactions/ MULTI、EXEC、…...

Spring三级缓存解决循环依赖问题

文章目录 1. 三级缓存解决的问题场景2. 三级缓存的差异性3. 循环依赖时的处理流程4. 源码验证 1. 三级缓存解决的问题场景 循环依赖指的是在对象之间存在相互依赖关系&#xff0c;形成一个闭环&#xff0c;导致无法准确地完成对象的创建和初始化&#xff1b;当两个或多个对象彼…...

Unity 中使用波浪动画创建 UI 图像

如何使用 只需将此组件添加到画布中的空对象即可。强烈建议您将此对象放入其自己的画布/嵌套画布中&#xff0c;因为它会弄脏每一帧的画布并导致重新生成整个网格。 注意&#xff1a;不支持切片图像。 using System.Collections.Generic; using UnityEngine; using UnityEng…...

支付功能测试用例测试点?

支付功能测试用例测试点是指在测试支付功能时&#xff0c;需要关注和验证的各个方面。根据不同的支付场景和需求&#xff0c;支付功能测试用例测试点可能有所不同&#xff0c;但一般可以分为以下几类&#xff1a; 功能测试&#xff1a;主要检查支付功能是否符合设计和业务需求…...

HFS 快速搭建 http 服务器

HFS 是一个轻量级的HTTP 服务工具&#xff0c;3.0版本前进提供Windows平台安装包&#xff0c;3.0版本开提供Linux和macOS平台的安装包。 HFS更适合在局域网环境中搭建文件共享服务或者安装配置源服务器。 甲 非守护进程的方式运行 HFS &#xff08;Ubuntu 22.04&#xff09; 一…...

学生专用台灯怎么选?双十一专业学生护眼台灯推荐

台灯应该是很多家庭都会备上一盏的家用灯具&#xff0c;很多大人平时间看书、用电脑都会用上它&#xff0c;不过更多的可能还是给家中的小孩学习、阅读使用的。而且现在的孩子近视率如此之高&#xff0c;这让家长们不得不重视孩子的视力健康问题。那么孩子学习使用的台灯应该怎…...

Go 常用标准库之 fmt 介绍与基本使用

Go 常用标准库之 fmt 介绍与基本使用 文章目录 Go 常用标准库之 fmt 介绍与基本使用一、介绍二、向外输出2.1 Print 系列2.2 Fprint 系列2.3 Sprint 系列2.4 Errorf 系列 三、格式化占位符3.1 通用占位符3.2 布尔型3.3 整型3.4 浮点数与复数3.5 字符串和[]byte3.6 指针3.7 宽度…...

antv/x6 导出图片方法exportPNG

antv/x6 导出图片方法exportPNG antv/x6 版本如下&#xff1a; "antv/x6": "2.14.1","antv/x6-plugin-export": "2.1.6",在文件中导入 import { Graph, Shape, StringExt } from antv/x6 import { Export } from antv/x6-plugin-exp…...

Decomposed Meta-Learning for Few-Shot Named Entity Recognition

原文链接&#xff1a; https://aclanthology.org/2022.findings-acl.124.pdf ACL 2022 介绍 问题 目前基于span的跨度量学习&#xff08;metric learning&#xff09;的方法存在一些问题&#xff1a; 1&#xff09;由于是通过枚举来生成span&#xff0c;因此在解码的时候需要额…...

C++经典面试题:内存泄露是什么?如何排查?

1.内存泄露的定义&#xff1a;内存泄漏简单的说就是申请了⼀块内存空间&#xff0c;使⽤完毕后没有释放掉。 它的⼀般表现⽅式是程序运⾏时间越⻓&#xff0c;占⽤内存越多&#xff0c;最终⽤尽全部内存&#xff0c;整个系统崩溃。由程序申请的⼀块内存&#xff0c;且没有任何⼀…...

Hadoop+Hive+Spark+Hbase开发环境练习

1.练习一 1.数据准备 在hdfs上创建文件夹&#xff0c;上传csv文件 [rootkb129 ~]# hdfs dfs -mkdir -p /app/data/exam 查看csv文件行数 [rootkb129 ~]# hdfs dfs -cat /app/data/exam/meituan_waimai_meishi.csv | wc -l 2.分别使用 RDD和 Spark SQL 完成以下分析&#xf…...

使用Spring Boot限制在一分钟内某个IP只能访问10次

有些时候&#xff0c;为了防止我们上线的网站被攻击&#xff0c;或者被刷取流量&#xff0c;我们会对某一个ip进行限制处理&#xff0c;这篇文章&#xff0c;我们将通过Spring Boot编写一个小案例&#xff0c;来实现在一分钟内同一个IP只能访问10次&#xff0c;当然具体数值&am…...

ES 数据迁移最佳实践

ES 数据迁移最佳实践与讲解 数据迁移是 Elasticsearch 运维管理和业务需求中常见的操作之一。以下是不同数据迁移方法的最佳实践和讲解&#xff1a; 一、数据迁移需求梳理 二、数据迁移方法梳理 三、各方案对比 方案 优点 缺点&#xff08;限制&#xff09; 适用场景 是否有…...

C++中低级内存操作

C中低级内存操作 C相较于C有一个巨大的优势&#xff0c;那就是你不需要过多地担心内存管理。如果你使用面向对象的编程方式&#xff0c;你只需要确保每个独立的类都能妥善地管理自己的内存。通过构造和析构&#xff0c;编译器会帮助你管理内存&#xff0c;告诉你什么时候需要进…...