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.


Required Jar files

To run this example, you need to load:

  • Spring Core jar files
  • Spring Web jar files
  • ojdbc14.jar file for oracle

download all the jar files for spring including core, web, aop, mvc, j2ee, remoting, oxm, jdbc, orm etc.


Create table

Here, we are using emp99 table of oracle 10g database which has 4 fields: id, name, salary and designation. Here, id is auto incremented which is generated by sequence.

spring crud table

Spring MVC CRUD Example

index.jsp

Emp.java

EmpDao.java

EmpController.java

web.xml

spring-servlet.xml

empform.jsp

empeditform.jsp

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


viewemp.jsp

Output

spring mvc crud output1

Click on "Add New Employee" link, you will see following form.

spring mvc crud output2

Fill data and click on save button. You will see employees list.

spring mvc crud output3

Now click on "edit" link, a form will appear with the data.

spring mvc crud output4

Now change the data of the form and click on "edit save" button.

spring mvc crud output5

Now click on "delete" link, you will see employees list with deleted record.

spring mvc crud output6

Download Spring MVC CRUD Example

We have created this application in MyEclipse IDE which already provides the jar files. If you use eclipse or other IDE's, you need to load the jar file for spring MVC.





Please Share

facebook twitter google plus pinterest tumbler

Latest 4 Tutorials