This tutorial is about Spring MultiActionController.
Using Spring MultiActionController class you can group related actions into a single controller class. Basically which similar to All the Spring applications you need to modify 3 sections here.
1. controller ( LinkController.java)
public ModelAndView add(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("multi", "message", "Add method called");
}
public ModelAndView remove(HttpServletRequest request,
HttpServletResponse response) throws Exception {
modelAndView.addObject("multi","message","Called on Remove method");
return modelAndView;
}
}
2. View (index.jsp) (You have to use '<' in relevant locations in tags)
a href="http://www.blogger.com/multi.html?action=add">Add
a href="http://www.blogger.com/multi.html?action=remove">Remove
(multi.jsp)
${message}
3. Application-servlet.xml (use '<' tag in appropiate locations)
bean id="multiPage" class="springmvc.web.LinkController">property name="methodNameResolver">
ref bean="paramResolver">
/ref>
/property>
/bean>
bean id="paramResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
property name="paramName">
/bean>
bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
property name="mappings">
props>
prop key="/multi.html">multiPage
/props>
/property>
/bean>
It's really simple. I'll continue this tutorial session with more Spring examples.
