Spring MVC控制器重定向使用URL参数而不是在响应中。

23 浏览
0 Comments

Spring MVC控制器重定向使用URL参数而不是在响应中。

我正在尝试在我的Spring MVC应用程序中实现RESTful URL。除了处理表单提交之外,一切都很好。我需要将重定向回原始表单或到一个"成功"页面。

@Controller

@RequestMapping("/form")

public class MyController {

@RequestMapping(method = RequestMethod.GET)

public String setupForm() {

// 做我的事情

return "myform";

}

@RequestMapping(method = RequestMethod.POST)

public String processForm(ModelMap model) {

// 处理表单数据

model.addAttribute("notification", "成功完成了!");

return "redirect:/form";

}

}

然而,根据Spring文档中的说明,如果你重定向,任何参数都会被放入URL中。而这对我来说不起作用。有什么优雅的解决方法吗?

0