3

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).

1
  • 1
    /secure/music/index is the RequestMapping of the other controller or is it a view to be resolved as something like /WEB-INF/view/secure/music/index.jsp ? Commented Mar 8, 2011 at 22:24

3 Answers 3

10

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!

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.