I am using Spring MVC with annotation configuration. I have a controller class for handling HTTP GET calls:
@Controller
@RequestMapping("/form")
public class FormController {
@RequestMapping(value = "/{table}/{identifier}/edit", method = RequestMethod.GET)
public ModelAndView getEditView(ModelMap map, @PathVariable String table, @PathVariable Object identifier) {
}
and at that URL a controller is sent for the processing form
@Controller
@RequestMapping("/form")
public class FormSaveController {
@RequestMapping(value = "/{table}/{identifier}/edit", method = RequestMethod.POST)
public ModelAndView saveView(WebRequest request, @PathVariable String table, @PathVariable Object identifier) {
}
When I try to start my container, Spring complains
Caused by: java.lang.IllegalStateException: Cannot map handler 'FormSaveController' to URL path [/form/{table}/{identifier}/edit]: There is already handler of type [class com.company.web.FormController] mapped.
This is similar to what I'm trying to do, not supported in Spring. The reason I'm trying to separate the controller from generating the form from the controller that saves the form is because I use Springs @ExceptionHandlerto handle any runtime exceptions that occur, and I would like to handle the exception to display the view differently than the exception to save the record.
, ( Springs @ExceptionHandler ?)