页面中引入引入:fileinput.js

js初始化:

<div class="modal-body"><input type="file" id="customerexcel" name="file"  accept=".xls,.xls" multiple/>
</div>

后台js进行初始化;

$("#customerexcel").fileinput({language : 'zh', // 设置语言uploadUrl : getProjectURL() + 'customer/drcustomer', // 上传的地址allowedFileExtensions : [ 'xls' ],// 接收的文件后缀showUpload : true, // 是否显示上传按钮showCaption : false,maxFileCount : 1// 是否显示标题}).on('fileuploaded', function(event, data) {alert(data.response.msg);})

最终的实现结果:

因为我这个是导入的excel,后台:

 @RequestMapping("/drcustomer")@ResponseBodypublic JSONObject drCustomer(HttpServletResponse response, HttpServletRequest request) {try {int count = 0;if (ServletFileUpload.isMultipartContent(request)) {MultipartHttpServletRequest fileUpload = (MultipartHttpServletRequest) request;MultipartFile file = fileUpload.getFile("file");Workbook workbook = Workbook.getWorkbook(file.getInputStream());Sheet sheet = workbook.getSheet(0);int rows = sheet.getRows();for (int i = 1; i < rows; i++) {Cell[] cells = sheet.getRow(i);Customer customer = new Customer();customer.setCode(cells[0].getContents());// 判断是否存在相同的代码if (customerService.isExistSameCode(customer.getCode())) {count++;continue;}customer.setCusname(cells[1].getContents());customer.setComtaxno(cells[2].getContents());customer.setAddresstel(cells[3].getContents());customer.setSj(cells[4].getContents());customer.setEmail(cells[5].getContents());customer.setAccount(cells[6].getContents());customer.setAddtime(new Date());customerService.save(customer);}String msg="";if(count>0) {msg="客户导入成功:有" + count + "在相同的客户代码,没有导入";}else {msg="客户导入成功";}return BuildJsonOfObject.getJsonString("1",msg);} else {return BuildJsonOfObject.getErrorJSONString("0", "文件上传失败");}}catch(BiffException e) {throw new RuntimeException("内容解析失败,请将当前excel另存为Microsoft Excel 97-2003 文件的*.xls");} catch (Exception e) {e.printStackTrace();return BuildJsonOfObject.getErrorJSONString("0", e.getMessage());}}

希望对有所帮助

bootstrap 文件上传fileinput相关推荐

  1. 基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用...

    Bootstrap文件上传插件File Input是一个不错的文件上传控件,但是搜索使用到的案例不多,使用的时候,也是一步一个脚印一样摸着石头过河,这个控件在界面呈现上,叫我之前使用过的Uploadi ...

  2. (转)基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用...

    http://www.cnblogs.com/wuhuacong/p/4774396.html Bootstrap文件上传插件File Input是一个不错的文件上传控件,但是搜索使用到的案例不多,使 ...

  3. Bootstrap文件上传插件File Input的使用

    1.文件上传插件File Input介绍 这个插件主页地址是:http://plugins.krajee.com/file-input,可以从这里看到很多Demo的代码展示:http://plugin ...

  4. BootStrap文件上传控件

    一.准备 1.插件下载地址:https://github.com/kartik-v/bootstrap-fileinput/ 下载后的压缩包解压文件夹内容如下: js:插件核心js代码,引用filei ...

  5. Bootstrap fileinput.js,最好用的文件上传组件

    本篇介绍如何使用bootstrap fileinput.js(最好用的文件上传组件)来进行图片的展示,上传,包括springMVC后端文件保存. 一.demo   二.插件引入 <link ty ...

  6. Bootstrap FileInput(文件上传)中文API整理

    下载地址.API和DOM地址(英语好的小伙伴可以看看) 下载地址:https://github.com/kartik-v/bootstrap-fileinput API文档 :http://plugi ...

  7. SSM框架 基于Bootstrap fileinput 实现文件上传功能

    SSM框架 基于Bootstrap fileinput 实现文件上传功能 pom.xml文件的配置 想要实现SSM框架实现多文件上传,必要的jar包必须要在pom.xml文件中引入.如下: <! ...

  8. 使用插件Bootstrap Fileinput文件上传

    最近的项目中有用到这个插件,觉得功能挺强大的. GitHub地址:https://github.com/kartik-v/bootstrap-fileinput/ git地址:https://gith ...

  9. php 表格导入excel插件,BootStrap Fileinput插件和表格插件相结合实现导入Excel数据的文件上传、预览、提交的步骤...

    这篇文章主要介绍了BootStrap Fileinput插件和Bootstrap table表格插件相结合实现文件上传.预览.提交的导入Excel数据操作步骤,需要的朋友可以参考下 bootstrap ...

最新文章

  1. linux的QQ浏览器里微信,移动端微信内置浏览器(或QQ浏览器)无法识别onclick事件的问题解决...
  2. IO多路复用之poll
  3. Matlab图形用户界面编程初级入门
  4. IOS开发 Block的学习
  5. 【哲学】自由意志是什么?(主观能动性)
  6. VS Code识别编辑规范,ESlint规则,VS Code保存去掉自动加分号、逗号、双引号
  7. Enterprise Library 2.0 Hands On Lab 翻译(3):数据访问程序块(三)
  8. ssm 项目cannot resolve package_前端工程化之创建项目
  9. js基本函数和基本方法
  10. 冒险岛单机版mysql_冒险岛单机版
  11. c语言opengles程序,OpenGL教程 OpenGL编程指南
  12. 励志幽默:郭德纲经典语句
  13. pop3邮箱怎么设置收发服务器端口,pop3设置(如何设置邮箱服务器?IMAP、POP3有何区别?)...
  14. Android以太网卡配置启动流程和双网卡同时支持的实现
  15. 1.GraphPad Prism 8软件安装
  16. thinkphpJWT
  17. 人工智能算法对发明创造的知识产权保护
  18. 聊聊soho办公-人们为什么越来越累
  19. 四年级计算机走进传统节日教案,四年级走进中国传统节日的作文范文
  20. 爬虫练习一(爬取笑话集)

热门文章

  1. Uva 10177 - (2/3/4)-D Sqr/Rects/Cubes/Boxes?
  2. 总结网络执法官,p2p终结者等网管软件使用arp欺骗的防范方法
  3. 极客新闻——18、领导和下属之间到底是什么样的关系?
  4. final关键字的这8个小细节,你get到几个?
  5. 某女程序员吐槽自己被男同事集体排挤!一个人吃饭,一个人敲代码!深深感觉到世界的恶意!...
  6. 在 Linux 命令行里与其他用户通信
  7. Apache Doris在美团外卖数仓中的应用实践
  8. 实习生离职,HR恼羞成怒:我要全行业封杀你
  9. 记一次内存溢出的分析经历
  10. 基于RESTful API 怎么设计用户权限控制?