Ok i got the way of using multiple controllers as i want as-
inedx.jsp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <a href="hello/One.html">Say Hello One</a><br> <a href="hello/Two.html">Say Hello Two</a><br> <a href="hi/One.html">Say Hi One</a> </body> dispatcher-servel.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" etc... <mvc:annotation-driven/> <context:component-scan base-package="com.fastek.crm3" /> <mvc:resources mapping="/resources/**" location="/resources/"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans> Here the two controllers and their methods are as-
@Controller @RequestMapping("/hello") public class HelloController { @RequestMapping(value="/One") public ModelAndView sayHello(@ModelAttribute("stdUser") StdUsers stdUser,BindingResult result) { System.out.println("/////called from one-----------"); String mess = "hello from one"; StdCheckAccessV chk = new StdCheckAccessV(); chk.setDFlag(1); stdUser.setChkAccessV(chk); return new ModelAndView(Screens.User, "message", mess); } @RequestMapping(value="/Two") public ModelAndView sayHelloTwo(@ModelAttribute("stdUser") StdUsers stdUser,BindingResult result) { System.out.println("/////called from two-----------"); String mess = "hello from two"; StdCheckAccessV chk = new StdCheckAccessV(); chk.setDFlag(1); stdUser.setChkAccessV(chk); return new ModelAndView(Screens.User, "message", mess); } } and
@Controller @RequestMapping("/hi") public class OtherController { @RequestMapping(value="/One") public ModelAndView sayHiOne(@ModelAttribute("stdUser") StdUsers stdUser,BindingResult result) { System.out.println("/////called from hi one-----------"); String mess = "hi from one"; StdCheckAccessV chk = new StdCheckAccessV(); chk.setDFlag(1); stdUser.setChkAccessV(chk); return new ModelAndView(Screens.User, "message", mess); } } Everything is working fine and as i understood from this example is appropriate Controller and method will be executed for related URL. As i am new born for Spring i just want to know that is there any way to controlling the Controller's call through dispatcher-servlet?I mean what i have to write in dispatcher-servlet to achieve that. Please help.
