Skip to content
Advertisement

Redirect to an external URL from controller action in Spring MVC

I have noticed the following code is redirecting the User to a URL inside the project,

JavaScript

whereas, the following is redirecting properly as intended, but requires http:// or https://

JavaScript

I want the redirect to always redirect to the URL specified, whether it has a valid protocol in it or not and do not want to redirect to a view. How can I do that?

Thanks,

Advertisement

Answer

You can do it with two ways.

First:

JavaScript

Second:

JavaScript
Advertisement