Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:38:53+00:00 2026-06-05T06:38:53+00:00

I am developing an application in which i am using spring framework 3.1.1 and

  • 0

I am developing an application in which i am using spring framework 3.1.1 and rest api. In it i have developed one rest controller which will on receiving “GET” request of url “/rest/host/{id}” will redirect the control to my view(form). Now after user fills up the form the posted data is also handled using rest. But in the method which i have written to handle post request all the parameters i am getting in one string which i want to parse and insert into the database. Can anybody tell which is the proper way to parse this spring data ? I can do it using String.split(“&”) but i don’t think it is correct way to do that. Here is my code.

<form:form method="POST" action="/nagios-sms-1.0/rest/snooze/host/" commandName="snoozeBean">
        <table width="100%" border="5" cellpadding="0" cellspacing="0">
            <tr>
                <td align="center">
                    <table width="50%" border="5">
                        <tr>
                            <td colspan="3"></td>
                        </tr>
                        <tr>
                            <td width="30%"><form:label path="contactNumber">Enter host address</form:label></td>
                            <td width="30%"><form:input path="contactNumber" /></td>
                            <td />
                        </tr>
                        <tr>
                            <td width="30%"><form:label path="snoozeTimeoutValue">Enter Snooze time</form:label></td>
                            <td width="30%"><form:input path="snoozeTimeoutValue" /></td>
                            <td />
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div id="buttons"
                                    style="margin-left: 20Px; margin-right: 100px;">
                                    <input type="submit" value="ok" /> <input type="reset" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>

REST code..

1) GET handler method

@RequestMapping(value = "/host/{hostId}", method = RequestMethod.GET)
public String snoozeHost(@PathVariable int hostId, ModelMap map) {

    Snooze snooze = new Snooze();
    snooze.setHost_id(hostId);
    map.put("snoozeBean", snooze);
    return "host";

}

2) POST handler method

    @RequestMapping(value = "/host", method = RequestMethod.POST)   
    @ResponseBody
    public String snoozeHostOK(@RequestBody String payload) {

            // i want to parse this payload data which contains my form fields.
        System.out.println("data : " + payload);
        return payload;
    }

Any kind of help will be appreciated. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:38:54+00:00Added an answer on June 5, 2026 at 6:38 am

    Instead of request body you can use @ModelAttribute and get all the form data bind in one pojo(snooze) filled by Spring Framework on post of the form.

    You need to declare snooze in your get and post request mapped method as @ModelAttribute. That will let you get all your values from the form.

    UPDATE

    See your modified code here.

    1. GET handler method

      @RequestMapping(value = "/host/{hostId}", method = RequestMethod.GET) 
      public String snoozeHost(@PathVariable int hostId, @ModelAttribute Snooze snooze, ModelMap map) { 
      
      snooze.setHost_id(hostId); 
      return "host"; 
      
      }
      
    2. POST handler method

      @RequestMapping(value = "/host", method = RequestMethod.POST)    
      @ResponseBody 
      public String snoozeHostOK(@ModelAttribute Snooze snooze) { 
      
      // you can use the setter methods of snooze object to retrieve the field values.
      return payload; 
      }
      

    Hope this helps you. Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a demo application using Last.FM API which will get list of
I am developing remoting application. Which one will be useful, dot net remoting using
I have been developing the application which can manage a device using SMS commands;
I am developing my application using spring-web-mvc... Now at my Controller it returns like
I am developing a GWT application which im using Spring Security to handle the
I'm currently developing a multi-tiered application, using MVC3 and Spring.NET all of which is
I'm developing a Grails (Version 1.3.3) Web-Application using the Grails Spring-Security Plugin, Spring-Security-Core-1.0.1 (which,
I am currently developing an application which is using the Dropbox iOS SDK version
I am developing an application in which i am using location service. Basically that
I'm currently developing an application which connects to a database using sqlalchemy. The idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.