Is there any difference between
public class Controller1 extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new AnotherController().handleRequest(request, response);
}
}
and
@Controller
public class Controller1 {
@RequestMapping ...
public String handleRequest() {
return "forward:/path_to_my_another_controller";
}
}
They’re similar, but not quite the same.
The second approach will create a new internal request to be forwarded on to the second controller, whereas the first one will re-use the same request object.
Whether or not that matters depends on what each of the controllers does to the request.
I’ve found that chaining controllers together using direct method calls is one of the more appealing aspects of Spring annotated controllers, it can make for a much more natural flow than chucking forwarded requests around.
As always, your mileage may vary.