Reputation: 51
I am new to this forum and have searched for my problem and although similar problems are mentioned but not the one that I am looking for. So here goes.
I have a payment popup in my application that can be called from any page of application and once user submits his payment details on popup, the browser redirects to paypal site and do some checks and return to my application after user confirmation.
Now in this callback method I need to forward the request to the original page which called the popup.
So now I have the app url in my callback method but can't seem to forward the request to it.
Example like below:
mv = new ModelAndView("forward:/secure/music/index");
OR
return "forward:/secure/music/index";
If I replace forward: with redirect: it works fine but I need to forward it, not redirect it (and hence initiate another request).
Upvotes: 3
Views: 18171
Reputation: 11
You should make the return type of your calling method as ModelAndView and make the call as follows- return new ModelAndView("forward:/secure/music/index");
It works for me, might work for you as well.
Upvotes: 1
Reputation: 9290
If you want to call a method of another controller, you could @Autowire
the second controller in your main controller and then call the desired method, passing the same request as parameter.
Hope this helps, it worked for me!
Upvotes: 10
Reputation: 8057
return new ModelAndView(viewName)
should work. However, if you need some values from model, you'll need to populate them before returning ModelAndView and return model as well.
Upvotes: 0