Nearby lessons
19 of 35Spring - MultiActionController
- Understand Spring - MultiActionController
- See working code examples
- Learn from common mistakes and Q&A
Learn Spring - MultiActionController step by step — simple explanations, complete programs with their output, common beginner mistakes, and exam-style MCQs.
MultiActionController — web.xml
Internal Flow
handleRequestInternal() method will be executed, it will return "viewName" property value as ModelAndView object , that is, logical name of the View, where ViewResolver will resolve the View Page and generate the respective webpage as response.
EX:
public class ParameterizableViewController extends Abstractcontroller{
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpservletResponse response)throws Exception{
return new ModelAndView(getViewName()); } }
MultiActionController
In general, in Spring WEB MVC applications, we will for each and every form or an URI we will prepare a separate Controller class depending on our requirement.
In the above approach, if we want to provide a particular Entity related actions like save, update, search and delete then we have to prepare seperate Controller classes like SaveController, UpdateController, SearchController, DeleteController... it will increase no of controller classes unnecessarily. In the above context, to reduce no of controller classes, SPring Framework has provided an alternative in the fomr of
"org.springframework.web.servlet.mvc.multiaction.MultiActionController".
The main intention of MultiActionController class is to group related actions into a single controller class.
If we want to use MultiAction controller class in Spring WEB MVC applications then we have to declare an user defined class as sub class to "MultiActionController" and we have to define action methods with the same incoming URI names.
public (ModelAndView | Map | String | void) actionName(HttpServletRequest request, HttpServletResponse response);
MultiActionController — index.jsp
Example:
MultiActionController — home.jsp
MultiActionController — addform.jsp
MultiActionController — searchform.jsp
MultiActionController — updateform.jsp
MultiActionController — student_edit_form.jsp
MultiActionController — deleteform.jsp
MultiActionController — student.jsp
MultiActionController — status.jsp
MultiActionController — HomeController.java
MultiActionController — StudentAction.java
MultiActionController — StudentDao.java
MultiActionController — StudentTo.java
MultiActionController — ds-servlet.xml
MultiActionController — web.xml
MultiActionController
To run the above application we need the following jar files in web application lib folder. o commons-logging-1.2.jar o ojdbc6.jar o spring-aop-4.3.9.RELEASE.jar o spring-aspects-4.3.9.RELEASE.jar o spring-beans-4.3.9.RELEASE.jar o spring-context-4.3.9.RELEASE.jar o spring-context-support-4.3.9.RELEASE.jar o spring-core-4.3.9.RELEASE.jar
- Key ideas of Spring - MultiActionController explained simply
- Ready-to-use code examples
- Exam-style questions at the end