Can someone please explain "How to upload CSV file to the database using Spring Hibernate MVC?"
Asked
Active
Viewed 1.1k times
1 Answers
6
Your client should create a multipart request.
A HTTP multipart request is a HTTP request that HTTP clients construct to send files and data over to a HTTP Server.
The Spring MVC handler method that handles such a request in its simplest form would look something like:
@RequestMapping(value="fileupload", method=RequestMethod.POST)
public void processUpload(@RequestParam MultipartFile file) throws IOException {
// process your file
}
the client side depends on your needs (and your client), here's an example made using the html form
<form id="fileuploadForm" action="fileupload" method="POST" enctype="multipart/form-data">
<label for="file">File</label>
<input id="file" type="file" name="file" />
<p><button type="submit">Upload</button></p>
</form>
The following tutorial gives you a more detailed insight http://www.studytrails.com/frameworks/spring/spring-mvc-file-upload.jsp

Community
- 1
- 1

Master Slave
- 27,771
- 4
- 57
- 55