Spring MVC form with multiple submit buttons

<div class="codeContainer">
	<form method="post" action="/login/apex/save/${apexType}/${currentId}">
		<textarea name="code" id="code">${body}</textarea><br/>
		<div class="btn-group">
			<input type="submit" value="Save" name="save" class="btn btn-primary">
			<input type="submit" value="Share" name="share" class="btn btn-primary">
		</div>
	</form>
</div>
	@SuppressWarnings("unchecked")
    @RequestMapping(method = RequestMethod.POST, value = "/save/{type}/{id}")
    public String updateClassDetail(@PathVariable("id") String id, @PathVariable("type") String type,
                    @RequestParam("code") String code, Map<String, Object> map,
                    @RequestParam(required=false, value="save") String save,
                    @RequestParam(required=false, value="share") String share){

  if (save!=null){
    ....
  } else if (share!=null){
    ...
  } 
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: