「Spring入門」1つのform中に複数のsubmitボタン対応サンプル

1.JSPコード
<form action="/employee/edit" method="post" >
<input type="text" id="userName" name="userName" />
<input type="text" id="addRess" name="addRess" />

<input type="submit" name="doBack" value="戻る" />
<input type="submit" name="doUpdate" value="更新" />
</form>

 

2.Javaコード
@Controller
@RequestMapping(“employee")
public class EmployeeController {

@RequestMapping(value = “edit", params = “doBack", method = RequestMethod.POST)
String doBack(/* xxx */) {
//some code
}

@RequestMapping(value = “edit", params = “doUpdate", method = RequestMethod.POST)
String doUpdate(/* xxx */) {
//some code
}
}

Java

Posted by arkgame