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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:22:18+00:00 2026-05-22T01:22:18+00:00

An item is displayed at this URL: /item/10101 using this Controller method: @RequestMapping(value =

  • 0

An item is displayed at this URL:

/item/10101

using this Controller method:

@RequestMapping(value = "/item/{itemId}", method = RequestMethod.GET)
public final String item(HttpServletRequest request, ModelMap model, 
    @PathVariable long itemId)
{
    model = this.fillModel(itemId);
    return "item";
}

The page contains a form that submits to the following method in the same controller:

@RequestMapping(value = "/process_form", method = RequestMethod.POST)
public final String processForm(HttpServletRequest request,
 @ModelAttribute("foo") FooModel fooModel,
    BindingResult bindResult,
    ModelMap model)
{

    FooModelValidator validator = new FooModelValidator();
    validator.validate(FooModel, bindResult);

      if (bindResult.hasErrors())
      {
        model = this.fillModel(fooModel.getItemId());
       return "item";
      }
    return "account";
}

If the validator finds errors in the form, it redisplays the item but instead of displaying it at the original url:

/item/10101

it displays it at its own url:

/process_form

Is it possible to redisplay the form at the original URL?

/item/10101

(I’ve tried getting the referrer and redirecting to it in processForm but then all of the model contents end up displayed as URL name/value pairs:)

@RequestMapping(value = "/process_form", method = RequestMethod.POST)
public final String processForm(HttpServletRequest request,
 @ModelAttribute("foo") FooModel fooModel,
    BindingResult bindResult,
    ModelMap model)
{
    String referrer = request.getHeader("referer");

    FooModelValidator validator = new FooModelValidator();
    validator.validate(FooModel, bindResult);

      if (bindResult.hasErrors())
      {
        model = this.fillModel(fooModel.getItemId());
       return "redirect:" + referrer;
      }
    return "account";
}
  • 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-05-22T01:22:19+00:00Added an answer on May 22, 2026 at 1:22 am

    Short answer: No.

    What happens is a server-side redirect (forward), which is within the same request, and so the submitted values are preserved (and displayed in the form)

    The url will change if you use a client-side redirect (return "redirect:item";), but in that case a new request will come and the submitted values will be lost.

    But here are two options that you have:

    • use the same URL in the mappings for both methods and distinguish them based on request method – GET for the former, POST for the latter. This might be confusing, so document it.

    • find / implement flash scope for spring-mvc. There’s nothing built-in. The flash scope means that values are preserved (in the session usually) for a submit and the subsequent redirect. This option includes the manual handling, by putting the submitted object in the session, and later retrieving & removing it

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

Sidebar

Related Questions

I've got a RESTful interface where the contents of a database are displayed. What
I am still new to MVC, so sorry if this is an obvious question:
I have been trying this from two days but unable to found a solution
I inherited a Django v1.2.4 application and am in the process of adding several
EventsActivity is one of my tabs (3 tabs have 3 activities). The question is:
I have a form which I call via AJAX (for use on a CMS)
I have read a lot about how to validate dynamically generated content in mvc
First off I'm new to Android and Java.. I have been trying to add
i have the following basic script to make an api call to vimeo and
What I have so far: I'm currently working on a Lift-based project for work.

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.