Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3.0 MVC :Redirect without parameters being added to my url

I'm trying to redirect without parameters being added to my url. I mean after a redirect, my url looks like this: .../success/?param1=xxx&param2=xxx.

This issue is exactly the same as this Spring MVC Controller: Redirect without parameters being added to my url

The response https://stackoverflow.com/a/16841663/384984 is what I'm looking (ignoreDefaultModelOnRedirect). The problem is that I'm using Spring 3.0. How can I solve it with this Spring version?

like image 575
Federico Lenzi Avatar asked Jul 16 '13 12:07

Federico Lenzi


1 Answers

  1. You can simply clear the Model map in your Controller method before redirect .

    model.asMap().clear();
    return "redirect:" + yourURL;
    
  2. Don't expose the model attributes at all.

    RedirectView view = new RedirectView(yourURL, true);
    view.setExposeModelAttributes(false);
    return new ModelAndView(view); 
    
  3. Hope this link helps you in finding a better solution, specially point (4) HandlerInterceptor for common reference data within the entire web application

like image 71
AllTooSir Avatar answered Sep 16 '22 19:09

AllTooSir