资源简介
文件上传并读取plupload与java后台的整合实例
代码片段和文件信息
package com.aisino.tax.controller.sz.invoice;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import com.aisino.tax.po.VXtglYh;
import com.aisino.tax.po.XtglGfxx;
@Controller
@RequestMapping(“/kpgl/invoice“)
public class InvoiceExcImpContoller {
// @RequestMapping(value={“/lodafp“} method={org.springframework.web.bind.annotation.RequestMethod.POST})
// @ResponseBody
// public String invoiceExc(HttpServletRequest request) throws FileUploadException IOException{
// boolean isMultipart = ServletFileUpload.isMultipartContent(request);
// DiskFileItemFactory factory = new DiskFileItemFactory();
// factory.setSizeThreshold(10000);
// String path = request.getSession().getServletContext().getRealPath(“/“) +
// “upload“ + System.getProperty(“file.separator“);
// File file =new File(path);
// factory.setRepository(file);
// ServletFileUpload upload = new ServletFileUpload(factory);
// upload.setSizeMax(10000);
// FileItemIterator iter = upload.getItemIterator(request);
// List> items = upload.parseRequest(request);
//
// //Iterator iter = items.iterator();
// return null;
// }
@RequestMapping(value={“/lodafp“} method={org.springframework.web.bind.annotation.RequestMethod.POST})
@ResponseBody
public Mapject> invoiceExc(HttpServletRequest request) {
Map backMap = new HashMap();
try {
VXtglYh yh = (VXtglYh)request.getSession().getAttribute(“user“);
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
request.getSession().getServletContext());
if (multipartResolver.isMultipart(request)) {
// 转换成多部分request
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest)request;
//取得request中的所有文件名
Iterator itr = multiRequest.getFileNames();
//定义缓存路径
String path = request.getSession().getServletContext().getRealPath(“/“) +
“upload“ + System.getProperty(“file.separator“);
//create upload file
File fileDir = new Fi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3310 2016-12-23 17:01 upload\fp_dr.html
文件 5788 2016-12-26 09:42 upload\InvoiceExcImpContoller.java
文件 390682 2016-12-22 14:05 upload\plupload-2.2.1.zip
目录 0 2016-12-26 09:28 upload
----------- --------- ---------- ----- ----
399780 4
相关资源
- java 微信小程序 文件上传
- commons-digester-2.0.jar
- 微信企业号OAuth2验证接口的2种(使用
- spring-context-2.5.xsd
- spring-jdbc4.0jar包
- spring-boot整合MySQL、mybatis、Juniteclips
- JSP+MVC+数据库的注册登录界面
- Javaweb图书借阅管理系统
- java springboot 切割分片上传大文件
- Spring定时任务包含jar包与代码和多种
- springMVC集成junit4需要的jar包
- 学生管理系统 mysql+springMVC
- 某课秒杀系统源码,SpringMVC+Spring+My
- java spring手写jdbcTemplate,实现查询多数
- java入门,进价,高阶到框架sshssm
- javamvc实现登录验证注册验证的小程序
- mybatis-spring-1.3.0.jar
- SpringBoot实战教程好评如潮58集
- spring boot+websocket前后端简单demo
- java Spring+openOffice实现office转pdf在线预
- JavaEE就业webSSHSSMJava仿在线教育网站
- spring-test-4.0.0.RELEASE.jar
- springside4.3.0 源码jar包
- 廖师兄的springboot项目视频
- spring data jpa jar包
- jsp实现的简单员工加班管理系统
- 传智播客SpringBoot视频+代码+笔记
- JavaEE开发的颠覆者 Spring Boot实战 完整
- 2019Java微服务架构(SpringBoot+SpringClo
- java ssm权限管理系统 慕课实战
评论
共有 条评论