13

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?

Community
  • 1
  • 1
Federico Lenzi
  • 1,632
  • 4
  • 18
  • 34

1 Answers1

28
  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

José Andias
  • 1,894
  • 2
  • 29
  • 31
AllTooSir
  • 48,828
  • 16
  • 130
  • 164
  • 2
    I believe you should not have that "redirect:" prefix in what you are passing to the RedirectView constructor; for obvious reason. :) – Jaroslav Záruba Jan 10 '15 at 10:19