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 7930113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:18:53+00:00 2026-06-03T20:18:53+00:00

I guess I’m looking more for advice than any specific coding solutions. Here’s the

  • 0

I guess I’m looking more for advice than any specific coding solutions. Here’s the scenario:

  • I have a form where a new user can be created
  • This form is accessed via a GET request through a Spring controller

    @RequestMapping(value = "/secure/clients", method = RequestMethod.GET)
    public String prepareNewClient(final Principal principal, final ModelMap map) {
        map.addAttribute("client", new Client());
        return "secure/clients";
    }
    
  • The form is presented, all works fine and I submit the new client using $.ajax({})

  • The submission triggers a POST request using the same URL to the following method on my controller

    @RequestMapping(value = "/secure/clients", method = RequestMethod.POST)
    public @ResponseBody JsonResponse saveClient(
        @ModelAttribute("client") final Client client,
        final BindingResult result,
        final Principal principal,
        final ModelMap map) {
    
        // validate input
        // save client
        // prepare JsonResponse object
    
        return jsonResponse;
    }
    

After completion, I want to keep the user on the same screen and have the form trigger a PUT instead of a POST. Which is fine, I can achieve that with jQuery, but as soon as I submit the form again, the client is not on the ModelMap anymore.

I have even tried adding the saved client to the ModelMap of my POST method but even that didn’t work.

I’m not entirely sure if I’m doing it the right way. To be honest, every tutorial I’ve seen uses more or less what I’m doing but NONE of them have a PUT request – mostly deal with creation of objects, which I don’t have an issue.

What I have in mind is that I might need to have a controller method mapping to /secure/clients/{clientId} with HTTP.GET and another controller method mapping /secure/clients/{clientId} with HTTP.PUT.

But I’m not sure if that makes sense, so I’m a bit lost.

  • Should I create my controllers entirely on JSON calls?
  • Should I redirect the user and forget about AJAX calls in this scenario?

Suggestions are more than appreciated. Thank you!

  • 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-03T20:18:55+00:00Added an answer on June 3, 2026 at 8:18 pm

    HttpMethod are not enterely support by web browsers. PUT requesr works great when two applications are working with Restfull API’s, but for browser compatibility, it is better to limit yourself to POST or GET request.

    You can also put a override parameter in your form to instruct the web server to handle the post as the desired method.

    <input type="hidden" name="_method" value="put"/> would do the job.

    Spring sf namespace takes care of that hidden field for you.

    <sf:form method="put">
    ....
    </sf:form>
    

    In addition, you can test your controller with restclient-ui to see if the problem comes from your WebServer or your client.

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

Sidebar

Related Questions

I guess I'm more of a newb than I thought? :) The weird thing
I guess this is more about SEO than wanting to support browsers with Javascript
Guess that I have a TextView that I want to update it in some
I guess I am looking for some kind of intro and see if anybody
I guess it is impossible, but I will ask it anyway. I have a
I guess there will be a very simple answer to this. But here goes.
I guess I don't give title nicely, anyways, I can explain it better here:
Guess we have simple model , e.g. let it be a Person { Name,
I guess I have an easy question, I have not found the right answer
I guess this have been both asked and answered before, but I don't really

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.