WowBow
WowBow

Reputation: 7593

Browser back button getting in to GET method of Spring MVC Controller instead of checking the cache

I am using Spring MVC 2.5. I have get and post methods for all the pages I have.

    @RequestMapping(value = "/offer", method = RequestMethod.GET)
    public ModelAndView getOffer(ModelMap model, HttpSession session) {

//code

        return new ModelAndView(OFFER_SETTING_PAGE, model);
    }


  @RequestMapping(value = "/offer", method = RequestMethod.POST)
    public ModelAndView postOffer(ModelMap model, @ModelAttribute("investorsEligiblitySetting")        

       //code

        return new ModelAndView("redirect:/servlets/ProcessAction/privateplacement/createoffer/additionalinformation");
    }

After passing the post method and displaying the next jsp file, when I try to hit the back button , instead of displaying the previous data from the cache (which is what I am looking for) it gets in to the get method of the specified url and causes some problems.

How can I make my application to look for cache first instead of getting in to a get method?

Upvotes: 0

Views: 2592

Answers (1)

CodeChimp
CodeChimp

Reputation: 8154

This is an old question, but I found this post that gives some ideas as to how to prevent the browser from resubmitting on the back button. You could also set something in your form when you handle the POST that the GET handler can look at to see if the POST already ran.

Upvotes: 1

Related Questions