开发者

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

开发者 https://www.devze.com 2023-01-17 18:04 出处:网络
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 ext

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

精彩评论

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

关注公众号