表单提交导入文件
来源:互联网 发布:suse linux 网络配置 编辑:程序博客网 时间:2024/05/17 08:58
———-html js 提交
<form id="import_form" method="post" enctype="multipart/form-data"> <input type="file" id="import_file" name="path" /> </form>//js:$('#import_form').form('submit', { url:"/saasoc/historyAccount/downHisAccount.do",success: function(res){ var data=JSON.parse(res); if(data.state=="ok"){ top.$.messager.alert('温馨提示','导入成功','warning'); }else{ top.$.messager.alert('温馨提示','导入失败','warning'); } }});
———-Java后台
//@RequestParam("path") CommonsMultipartFile获取导入文件路径public @ResponseBody JsonResp downHisAccount(@RequestParam("path") CommonsMultipartFile files) throws Exception {JsonResp resp = null;ImportParams params = new ImportParams();//第三方导入参数params.setVerifyHanlder(new ImporterVerifyHandler());// 导入数据,files.getInputStream()导入文件,解析导入数据List<ImportAccount> list = ExcelImportUtil.importExcel( files.getInputStream(), ImportAccount.class, params);//ImportAccount 导入的实体类信息,且加上导入的注解信息/**例如public class ImportAccount {@Excel(name = " 姓名")private String cname; // 姓名}**/if (list.size() > 0 && list != null) { int his = hisAccountService.addImport(list); //批量添加操作 if (his == 1) { resp = new JsonResp(JsonResp.STATE_OK); } else { resp = new JsonResp(JsonResp.STATE_ERR); }} else { resp = new JsonResp(JsonResp.STATE_ERR); resp.setErrMsg("该excel文件无数据,请检查!");}return resp;}
———-该方法只使用少于1万条数据的导入
阅读全文
1 0
- 表单提交导入文件
- web端实现表单提交poi导入excel文件
- 提交表单--文件
- 表单提交文件上传
- 提交表单上传文件
- 【html+css】表单提交,允许文件提交
- libcurl提交表单上传文件
- html5异步提交文件表单
- HttpURLConnection 提交表单+ 上传文件
- libcurl提交表单上传文件
- Ajax表单提交上传文件
- android端表单提交文件
- JQ ajax提交表单文件
- 文件上传,表单提交插件
- php上传文件--表单提交
- 模拟表单提交文件和变量
- 无刷新文件上传 ajax提交表单
- 无刷新文件上传 ajax提交表单
- TCP三次握手与四次挥手
- oracle 10g正则表达式REGEXP_LIKE用法
- 迭代方法总结
- 运营商劫持
- MySQL 修改报错 You can't specify target table 'tb_trade' for update in FROM clause
- 表单提交导入文件
- TextView+Spinner的使用
- 反转链表
- 端口号及URG和PSH的区别
- 事物的特性
- c++入门
- SpringBoot整合SpringSecurity,SESSION 并发管理,同账号只允许登录一次
- 浏览器缓存机制
- 机器人程序设计——之如何正确入门ROS | 硬创公开课