开发者

Why do my anchor tags contain my request context path before the path I specify?

I'm using Apache Tomcat 6.0.26 with java servlets and JSPs.

Whe开发者_如何学运维never I'm trying to link to an external website, my anchor tags always contain my request context path before the external link. For example if my context path is http://localhost:8084/MyWebPage/ and I'm trying to link to www.google.com via this tag:

<a href="www.google.com">Google</a>

My anchor tag tries to go to http://localhost:8084/MyWebPage/www.google.com instead of www.google.com.

What am I missing here?

Thanks in advance.


You're missing the scheme. Add it:

<a href="http://www.google.com">Google</a>

It makes the link absolute. Right now you've a relative link which is relative to the current request URL and its behaviour is as per the specification.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜