Spring MVC Excel File Upload to Oracle Database Example

File Uploading is a very common task in any web application. Today we will learn about Spring File upload, specifically Spring MVC File Upload to upload Excel file and save its data into Oracle DB tables.

Spring uses MultipartResolver interface to handle the file uploads in web application. Below are two of the implementation :

  1. StandardServletMultipartResolver – Servlet 3.0 multipart request parsing.
  2. CommonsMultipartResolver – Classic commons-fileupload.jar

Tools used in this article :

  1. Spring 4.3.7.RELEASE
  2. Maven 3
  3. Tomcat 8.5

1. Project Structure

2. Project Dependency

First of all we need to add project dependency in our pom.xml

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>







<!– compile only, deployed container will provide this –>

<!– Logging –>







3. Spring MVC configuration

To enable file upload we will add MultiPart bean in our spring mvc configuration file springDispatcherContext.xml  org.springframework.web.multipart.commons.CommonsMultipartResolver

Our final Spring configuration file looks like below.



Notice I am setting max upload file size for CommonsMultiPartResolver using “maxUploadSize”

4. Spring File Upload Controller Class

Controller class should have handler method to return view and also to process file upload. Controller class is responsible for mapping the request from url and executing it in the java layer.




5. Spring View – upload.jsp



6. Web.xml



7. Service Layer

This layer will process excel file and read data from file and construct java object to save into DB. Here we have used apache POI to parse Excel data and read from excel sheet.



8. DAO Layer to persist data into DB

DAO layer is responsible for persisting file data into DB tables in same format as in input file.



9. Sample Input Excel file

Below is the input excel file which is parsed and processed by our SpringFileUpload project. It read all the rows one by one and then process it and saves to oracle Database.

10. Spring File upload Result

Type below url in browser and open welcome page to upload file.


Upload success:


Download Sample from GitHub.com


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

newest oldest most voted
Notify of

where is basedao,Where is ExcelTemplatev? In the Above Example?

Anshu (@DeveloperAnshu)

Thank you


why i keep getting request method ‘post’ not supported