Spring MVC Controller:没有参数的重定向被添加到我的URL [英] Spring MVC Controller: Redirect without parameters being added to my url

查看:322
本文介绍了Spring MVC Controller:没有参数的重定向被添加到我的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重定向而不将参数添加到我的网址。

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

@Controller
...
public class SomeController
{
  ...
  @RequestMapping("save/")
  public String doSave(...)
  {
    ...
    return "redirect:/success/";
  }

  @RequestMapping("success/")
  public String doSuccess(...)
  {
    ...
    return "success";
  }

重定向后,我的网址看起来总是这样: ... /成功/参数1 = XXX&安培; param2的= XXX
由于我希望我的URL有点RESTful,并且在重定向后我从不需要params,我不希望它们被重定向添加。

After a redirect my url looks always something like this: .../success/?param1=xxx&param2=xxx. Since I want my URLs to be kind of RESTful and I never need the params after a redirect, I don't want them to be added on a redirect.

任何想法如何摆脱它们?

Any ideas how to get rid of them?

推荐答案

在Spring 3.1中使用选项ignoreDefaultModelOnRedirect 以禁用自动添加模型属性重定向:

In Spring 3.1 use option ignoreDefaultModelOnRedirect to disable automatically adding model attributes to a redirect:

<mvc:annotation-driven ignoreDefaultModelOnRedirect="true" />

这篇关于Spring MVC Controller:没有参数的重定向被添加到我的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆