i have to call one controller on the basis of first controller i have to call another controller ……
but this is not working in spring 3 mvc……..
@Controller
public class ajaxContoller {
@RequestMapping(value="/mmiFacade",method=RequestMethod.POST)
public @ResponseBody String mmiFacade(@RequestParam String sType){
String forwardName = "";
if (sType.equalsIgnoreCase("Pincode")) {
forwardName = "forward:/pincodeAction";
} else if (sType.equalsIgnoreCase("Locality")) {
forwardName = "forward:/localityAction";
} else if (sType.equalsIgnoreCase("Patient")) {
forwardName = "forward:/patientAction";
} else if (sType.equalsIgnoreCase("Dlhdata")) {
forwardName = "forward:/Dlhdata";
}
return forward;
}
@RequestMapping(value="/pincodeAction",method=RequestMethod.POST)
public @ResponseBody String ajax(){
return "hiii";
}
@RequestMapping(value="/localityAction",method=RequestMethod.POST)
public @ResponseBody String ajax1(){
return "hiii1";
}
}
You should return modelandview object. view name starting with “forward:/” will do the job, otherwise Spring does not even try to interpret the response.
Another option to implement a switch and to invoke other mapping as simple call to anther java function.