Spring MVC Hibernate MySQL – Multiple Controllers

Spring MVC Hibernate MySQL – Multiple Controllers:
In our previous example we implemented Spring MVC Hibernate MySQL CRUD Operations (Here). In this article we are going to see how to use Multiple Controllers using Spring MVC.

In the below example, We are going to create 2 entities Employee and Manager and will have separate controllers for both these entities. Let us see how to add, view and delete. Edit operation is same as we discussed in previous example (Here), So i have not implemented Edit operation in this example.

Project Structure:

POM.xml

com.javainfinite.model:
Employee.java

Manager.java

com.javainfinite.dao:
EmployeeDAO.java

ManagerDAO.java

EmployeeDAOImpl.java

ManagerDAOImpl.java

com.javainfinite.service
EmployeeService.java

ManagerService.java

EmployeeServiceImpl.java

ManagerServiceImpl.java

spring-config.xml

web.xml

employee.jsp

manager.jsp

Output:

After Adding,

Deleting Employee,

On Clicking Manager Link,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Read More

Spring MVC – Multiple Submit Buttons Example

Spring MVC – Multiple Submit Buttons Example

Let us see an example code today for Spring MVC that has multiple submit buttons in one form. This is Second spring mvc tutotial. (Spring MVC example1 is here).

In this example, We are going to have 2 submit buttons. “Success” and “Failure”. When user clicks “Success” button it should pass to Controller and do some functions and take the user to respective page. Similarly when user clicks “Failure” it should go to Controller and then pass it to respective page.

Structure:
Structure

com.javainfinite.pojo
employee.java

page1.jsp

page2.jsp (Success click page)

page3.jsp (Failure click page)

com.javainfinite.controller
econtroller.java

applicationContext.xml

dispatcher-servlet.xml

Output:
output1

On Clicking Success Button,

output2

On clicking Failure Button,

output3

 

 

 

 

 

 

 

Read More

Spring MVC Example – Simple Form Handling

Spring MVC Example – Simple Form Handling:
Let us see an example of Spring MVC (form handling method). This application is tested using NetBeans.

Files to be Created:
Login.jsp
success.jsp
employeeLogin.java
employeeController.java

Structure:
structure

Login.jsp

success.jsp

employeeController.java

employeeLogin.java

applicationContext.xml

dispatcher-servlet.xml

Output:

op1

op2

op3

 

 

 

 

 

Read More