Spring MVC Annotation Multi Action tutorial with example

We can have more than one operation in Single controller class, also spring allow us to write lot of flexible methods to handle request 


package com.candidjava.springmvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@RequestMapping(value = "/customer")
public class CustomerController

	@RequestMapping(value = "/add.htm", method = RequestMethod.GET)
	public ModelAndView add() throws Exception

		ModelAndView mv = new ModelAndView("page");
		mv.addObject("msg", "add() method");

		return mv;

	public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) throws Exception

		return new ModelAndView("page", "msg", "delete() method");


	public String update() throws Exception

		return "page1";


	public String list() throws Exception

		return "page2";







            Spring MVC Multi Action maven zip

            Spring MVC Multi Action war

Related Post