本文介绍了Spring MVC Controller重定向使用URL参数而不是响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的Spring MVC应用程序中实现RESTful url。一切都很好,除了处理表格提交。我需要重定向回原来的形式或成功页面。
I am trying to implement RESTful urls in my Spring MVC application. All is well except for handling form submissions. I need to redirect either back to the original form or to a "success" page.
@Controller
@RequestMapping("/form")
public class MyController {
@RequestMapping(method = RequestMethod.GET)
public String setupForm() {
// do my stuff
return "myform";
}
@RequestMapping(method = RequestMethod.POST)
public String processForm(ModelMap model) {
// process form data
model.addAttribute("notification", "Successfully did it!");
return "redirect:/form";
}
}
但是当我在为我提供了我需要的工作,直到Spring MVC提供的功能(潜在在3.0.2版本)。虽然我只是实现了他们暂时的类,并将过滤器添加到我的Web应用程序上下文。工作太棒了!
http://jira.springframework.org/browse/SPR-6464 provided me with what I needed to get things working until Spring MVC offers the functionality (potentially in the 3.0.2 release). Although I simply implemented the classes they have temporarily and added the filter to my web application context. Works great!
这篇关于Spring MVC Controller重定向使用URL参数而不是响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!