---
title: "use redirect to void duplicate submission "
author: "breezylee"
date: "2012-09-14T15:51:54Z"
tags: []
categories: ["企业架构"]
slug: "use-redirect-to-void-duplicate-submission"
draft: false
lastmod: "2012-09-14T15:53:08Z"
id: 1678689
url: "https://breezylee.iteye.com/blog/1678689"
---

《Spring in Action3》笔记：

```
@RequestMapping(method=RequestMethod.POST)
public StringaddSpitterFromForm(@Valid　Spitter　spitter,　BindingResult bindingResult){
　　if(bindingResult.hasErrors()){
　　     return"spitters/edit";
　　}
　　spitterService.saveSpitter(spitter);
　　return "redirect:/spitters/"+spitter.getUsername();
}
```

 

By　redirecting to another page, we can avoid duplicate submission of the form if the user  
clicks the Refresh button in their browser.