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