Javatpoint Logo
Javatpoint Logo

Spring MVC CRUD Example

CRUD (Create, Read, Update and Delete) application is the most important application for creating any project. It provides an idea to develop a large project. In spring MVC, we can develop a simple CRUD application.

Here, we are using JdbcTemplate for database interaction.

Create a table

Here, we are using emp99 table present in the MySQL database. It has 4 fields: id, name, salary, and designation. Here, id is auto incremented which is generated by the sequence.

Spring MVC CRUD Example

Spring MVC CRUD Example

1. Add dependencies to pom.xml file.


2. Create the bean class

Here, the bean class contains the variables (along setter and getter methods) corresponding to the fields exist in the database.

3. Create the controller class

4. Create the DAO class

Let's create a DAO class to access the required data from the database.

5. Provide the entry of controller in the web.xml file


6. Define the bean in the xml file


7. Create the requested page


8. Create the other view components



Here "/SpringMVCCRUDSimple" is the project name, change this if you have different project name. For live application, you can provide full URL.



Spring MVC CRUD Example

On clicking Add Employee, you will see the following form.

Spring MVC CRUD Example

Fill the form and click Save to add the entry into the database.

Spring MVC CRUD Example

Now, click Edit to make some changes in the provided data.

Spring MVC CRUD Example

Now, click Edit Save to add the entry with changes into the database.

Spring MVC CRUD Example

Now, click Delete to delete the entry from the database.

Spring MVC CRUD Example

Download SQL File

Download SQL File

Download MYSQL-connector.jar file

If you are not using maven, download MYSQL-connector.jar.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA