Creating a UI form and process with spring mvc controller

This is a basic tutorial of getting form values to spring controller and printing them in console.

we have a page called createoffer.jsp which it will take form values.


<%@ page language="java" contentType="text/html; charset=US-ASCII"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Insert title here</title>

//we transferred the form request to /docreate controller using expression language and then we passed the form 
//data to docreate controller model object.
<form method="get" action=${pageContext.request.contextPath}/docreate>
<tr><td>Name: </td><td><input name="name" type="text"/></td></tr>
<tr><td>Email: </td><td><input name="email" type="text"/></td></tr>
<tr><td>Your offer: </td><td><textarea name="text" rows="10" cols="10"></textarea></td></tr>
<tr><td> </td><td><input value="Create advert" type="submit"/></td></tr>


public String doCreate(Model mode, Offer offer) {

return "offercreated";


Offer [id=0, name=krishna,, text=hello, any doughts on spring clear here. Its Free!]


the complete source code is here

Balakrishna Pendyala

Author: Balakrishna Pendyala

Balakrishna is a Software Engineer working in Media Streaming Domain, and also worked on Banking and Health Care domains. His areas of interest include Object Oriented Design, SOLID Design principles, Restful Web Services and Open Source softwares including Spring, Spring Boot, and Hibernate.

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Leave a Reply

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