Spring MVC RESTFul Service POST Data Complete example
In this tutorial you will see how to develop Spring MVC RESTFul service and post data through HTML page and also test it through Postman – REST client for chrome efficient way to test RESTFul Service. Here we will post data with two value name and another string value with multiple line and process it. Please follow steps below:
- Create maven project name: SpringMVCRESTFulService
- Final project structure:
SpringMVCController.java: In this class I will show you how to process form request data using below two method parameter:
- @RequestBody: We will process form data using @RequestBody. Here all request comes as one object which is whole form request and data will be seperated by name value pair as (name=Java Honk&stringValue=Post data test. Also you will see if request send as multiple line in string how to fetch each line from it.
- @RequestParam: We will process form data using @RequestBody. Here request will come as separate form field parameter and will be process separately.
- We will use tomcat server to run this code. Once you download and configure project test data as below:
- As you see above we have two form on JSP page to test data using two different way. Click submit button separately you will see below output:
- Now test this service using Postman – REST client for chrome. You could add this extension in your chrome browser and open your Postman rest client and enter data as below:
- You could use this URL to see New Line Code (HTML, Java, URL & Escape Sequence)
- That’s it.
Download Project: SpringMVCRESTFulService