I coded a wee login controller. It has an onSubmit method which logs in the user. If the login is successful I want to show the front page without having to redirect. The front page needs content from some other model. Beca开发者_开发知识库use my LoginController
already has a LoginModel
it can't also have the InformationModel
.
Is there some way to get a pointer on the InformationModel
? Or some call to get the ModelAndView
of the InformationController
? That controller provides a handleRequest
method.
I think this is more a fundamental question, but if you need code to answer it I will supply it.
I',m not sure if I get your question correctly, but
a.) You can add multiple models on your ModelAndView object. Use:
modelAndView.addObject("informationModel", informationModelObject);
b.) If successful login, set the view to your front page view:
modelAndView.setView("frontPageView");
To access your InformationController on your LoginController, you can autowire it =)
@Autowired
InformationController informationController;
@RequestMapping( ... ) // assuming you define it here
public ModelAndView onSubmit(... ) {
// .. code here
if (loginsuccess) {
InformationModel informationModelObject = informationController.handleRequest(...);
modelAndView.addObject("informationModel", informationModelObject);
modelAndView.setView("frontPageView");
}
else {
modelAndView.setView("loginFailView");
}
return modelAndView;
}
精彩评论