spring-mvc - Spring MVC Redirect 显示 applicationinfo.properties 中的参数如何删除它们

标签 spring-mvc redirect parameters

使用这种方式后,我的属性文件中的参数在重定向主页时会显示在 URL 中。 (例如: http://localhost:8080/home/?myproj.test.param.url=http%3A%2F%2Flocalhost%3A8080%2F 。myproj.test.param.url 是我的应用程序信息文件中的一个属性)

public RedirectView save(@ModelAttribute("xxxxx") XXXX xp, HttpServletRequest request, Model model, HttpSession session, RedirectAttributes ra) {

    return new RedirectView("/home/");

}

我尝试在我的 Web Config 中将其设置为 false。但还是没用。 -requestMappingHandlerAdapter.setIgnoreDefaultModelOnRedirect(true);

我正在使用 spring-webmvc-4.3。我使用 spring-boot-starter-parent 1.5.15 来构建。

最佳答案

对于任何寻找示例代码的人。下面的代码有效:

public RedirectView save(@ModelAttribute("xxxxx") XXXX xp, HttpServletRequest request, Model model, HttpSession session, RedirectAttributes ra) {
        RedirectView redirectView = new RedirectView("/home/");
        redirectView.setExposeModelAttributes(false);
        return redirectView;
}

关于spring-mvc - Spring MVC Redirect 显示 applicationinfo.properties 中的参数如何删除它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54919629/

相关文章:

java - Spring Security CSRF token 不适用于 AJAX

.htaccess - 将 .htaccess 重定向到 ssl https

python - 如何从 POST 方法重定向到 web.py 中的另一个处理程序

java - Spring MVC - 在单个 @requestmapping 中处理多个提交按钮

spring-mvc - 蒲公英数据表出错 - 无法加载资源 : the server responded with a status of 404 (Not Found)

Spring boot 1.5.9,访问 Docker 容器中的资源镜像时出现 404 错误

php - 重定向到非 https 页面

jquery - 为什么 jQuery.each() 和 jQuery.grep() 有不同的参数顺序?

c# - 将命令插入到 C# 中的调用命令中

types - 在 F# 中显式指定参数类型