Multiple button submit spring

Multiple button submit spring

If you are trying to Multiple button submit spring MVC post to a form, you could use single operation with @RequestParam and use condition to check which button has been clicked as below:

On jsp page:

<input class="button" type="submit" name="save" value="Save" />
<input class="button" type="submit" name="renew" value="Renew" />

 

On controller page:

@RequestMapping(value = "/submtiMultipleButtonExample.web", method = RequestMethod.POST)
	public String submtiMultipleButtonExample(
			@RequestParam("submit") String submitValue) {

		if (submitValue.equalsIgnoreCase("Save")) {
			return "jspPage";
		} else if (submitValue.equalsIgnoreCase("Renew")) {
			return "jspPage";
		} else {
			return "jspPage";
		}

}

Multiple button submit spring

 

Leave a Reply

Your email address will not be published. Required fields are marked *