1. There is a solution to save it to a certain location on the server and then read it. You need to pay attention to the unique file name and delete it after processing. 2. That’s not right. You can get a file by uploading it. It is a File object. I forgot how to do it
ServletInputStream extends InputStream Of course, forced conversion cannot be done. You can read ServletInputStream from the buffer and then convert it to InputStream (if you don’t mind it). The normal way is to create a temporary file on the server (if you can’t see it) You can delete it) You can try using springmvc, 1.@RequestParam(value="file",required = false)MultipartFile file //Receive parameters 2. But you also need to build a file saving path
String path = request.getSession(true).getServletContext().getRealPath("/upload");
String fileName = new Date().getTime()+file.getOriginalFilename();
3.Save the file
File targetFile = new File(path,fileName);
file.transferTo(targetFile)
You try the example on the official website.
1. There is a solution to save it to a certain location on the server and then read it. You need to pay attention to the unique file name and delete it after processing.
2. That’s not right. You can get a file by uploading it. It is a File object. I forgot how to do it
What version of POI? In the construction method of XSSFWorkbook, one parameter is obviously InputStream
ServletInputStream extends InputStream Of course, forced conversion cannot be done. You can read ServletInputStream from the buffer and then convert it to InputStream (if you don’t mind it). The normal way is to create a temporary file on the server (if you can’t see it) You can delete it)
You can try using springmvc,
1.@RequestParam(value="file",required = false)MultipartFile file //Receive parameters
2. But you also need to build a file saving path
3.Save the file
4.POI...