2013-08-01 114 views
0

我正在使用以下配置控制器重定向到外部URL。在Spring MVC中重定向到外部URl

我的應用程序基本URL是http://www.testcebs.com:8080/SpringSecDemo11/

@RequestMapping(value = "/tryIt", method = RequestMethod.GET) 
public String goToGoogle() { 
    String redirectUrl = "www.google.com"; 
    return "redirect:" + redirectUrl; 
} 

在調用 「/ tryIt」 URL它顯示404和URL轉到

http://www.testcebs.com:8080/SpringSecDemo11/www.google.com

請提出辦法脫身的它。

問候, Pranav

+0

是的這解決了我的問題 –

回答

1

前綴的網址字符串的協議,即http://www.google.com

final String redirectUrl = "redirect:http://www.google.com"; 
return redirectUrl;