Spring 3.0 MVC:没有参数的重定向被添加到我的URL [英] Spring 3.0 MVC :Redirect without parameters being added to my url
问题描述
我正在尝试重定向,而不将参数添加到我的网址。我的意思是在重定向之后,我的网址看起来像这样:... / success /?param1 = xxx& param2 = xxx。
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¶m2=xxx.
此问题与此完全相同 Spring MVC控制器:不添加参数的重定向我的网址
回复 https://stackoverflow.com / a / 16841663/384984 就是我正在寻找的东西( ignoreDefaultModelOnRedirect )。问题是我使用的是Spring 3.0。我怎么能用这个Spring版本解决它?
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?
推荐答案
-
你可以简单地清除
模型
在重定向之前在控制器
方法中映射。
You can simply clear the
Model
map in yourController
method before redirect .
model.asMap().clear();
return "redirect:" + yourURL;
不要公开模型属性。
Don't expose the model attributes at all.
RedirectView view = new RedirectView(yourURL, true);
view.setExposeModelAttributes(false);
return new ModelAndView(view);
希望此链接可帮助您找到更好的解决方案,特别是指向(4) HandlerInterceptor
用于整个Web应用程序中的公共参考数据
Hope this link helps you in finding a better solution, specially point (4) HandlerInterceptor
for common reference data within the entire web application
这篇关于Spring 3.0 MVC:没有参数的重定向被添加到我的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!