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.

How do you implement this in a dynamic programming environment.
ReplyDeleteActually this is really important when you want to use multiple methods in same controller. As in the example you have the opportunity to call required method in a single controller....
ReplyDeleteThis code is working. But what i dont understand is why we need a controller class. we can manupilate the same thing using threads for that matter.. please explain.
ReplyDelete