Springboot MVC – Passing Values from JSP to Controller

Springboot MVC – Passing Values from JSP to Controller

In this article let us see how to pass values from JSP page to Spring Controller. We are going to implement MVC with SpringBoot.

For understanding Springboot with MVC – Basic example – Please refer here

In this example, We are going to have a Employee Bean, Controller and a main class. We are going to have 2 JSP pages, home.jsp and welcome.jsp.

home.jsp page loads when the springboot application is deployed, we will enter the name there and the name will be passed to controller and from controller it will go to welcome.jsp and will display the name.

In order to use spring form in the JSP pages, we require to include this taglib

<%@ taglib uri=”http://www.springframework.org/tags/form” prefix=”form”%>

Here is the Project Structure,





In the above code, We have declared model.addAttribute(“Employee”, employee); where employee is a bean and is autowired. So the bean is made available.

What will happen if we don’t declare Bean?
Well, if we dont make the bean available, we will be hitting an exception – BindingResult nor plain target object for bean name available as request attribute.

So when creating an mvc project, make sure bean is available.








Download code here

Leave a Reply

Your email address will not be published. Required fields are marked *