0

I hace this piece of code in my JSP:

<a href="<c:out value="${item.urlForOnline}"    />"  target="_blank"><c:out value="${item.urlForOnline}"    /></a>     

The value of ${item.urlForOnline} is www.google.com

But when I click to the link the browser is redirected to http://127.0.0.1:7001/myApp/search/www.google.com

I set the value ot the item object in the spring controller:

model.addAttribute("item", item);   
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
  • Where are you setting the ${item.urlForOnline} value? – Perdomoff Jan 08 '16 at 16:28
  • 1
    The href is interpreted as a relative URL. See [this question](http://stackoverflow.com/questions/8997790/why-does-an-anchor-tags-href-values-need-http-preprended-to-the-url). – uzonyib Jan 08 '16 at 17:17

1 Answers1

0

Browser is taking www.google.com as relative rosource of your site.

You can simply solve this problem by providing the protocol as replacing www.google.com with http://www.google.com.

Arjun
  • 3,248
  • 18
  • 35