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

后端 未结 6 419
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 04:58

I\'m trying to redirect without parameters being added to my URL.

@Controller
...
public class SomeController
{
  ..         


        
6条回答
  •  [愿得一人]
    2020-11-30 05:09

    In Spring 3.1 a preferred way to control this behaviour is to add a RedirectAttributes parameter to your method:

    @RequestMapping("save/")
    public String doSave(..., RedirectAttributes ra)
    {
        ...
        return "redirect:/success/";
    }
    

    It disables addition of attributes by default and allows you to control which attributes to add explicitly.

    In previous versions of Spring it was more complicated.

提交回复
热议问题