Struts页面转向后所需资源的定位问题

对于图片,样式表,js文件等资源的路径用相对路径表示时,以http://localhost:8080/tag/tree/treeAjax.jsp 访问时可以正常访问的,但是经Struts跳转:

http://localhost:8080/tag/renderTreeAction.do 后,这些资源的定位都出现了问题,其原因是这两个url到达同一个jsp后,其相对路径的参照物不同,解决方法是<html:base/>标签,使用此标签后,所有相对路径都已改jsp的路径为参照物.

The base href tag is one of several tags in html that aid in reducing the amount of repetitive text in your document. By declaring a base href you are in affect telling the browser that all relative links contained within the document start from that specified base location. This is a great time saver when developing html on your computer by allowing you to view how the document will look and behave when placed on the server without actually having to do so

<html>
<head>
<title>
CodeAve.com(Base Reference)
</title>
<base href=
"http://www.codeave.com"
>
</head>

 

<!-- The base href command will set a location from which all
relative links will be driven from. -->

<body bgcolor="#FFFFFF">
Hyperlinks
<p>

<a href=html>CodeAve.com - HTML</a>


即:href=base.href/html

createddue to the base href. Place the mouse cursor over the linkand the full address will appear in the lower left of the browser

 

Without the base href this link would be directed to the relative location of the page--此页面的相对位置#html
(In this case http://www.codeave.com/html/html
which does not exist) -->

<p>
Image
<p>

<img src=codeavelogo.gif>
<!-- The full url http://www.codeave.com/codeavelogo.gif
will be created due to the base href.

Without the base href this image tag would
be directed to the relative location of the page
(In this case http://www.codeave.com/html/codeavelogo.gif
which does not exist) -->

 

</body>
</html>

<!-- The full url http://www.codeave.com/html will be
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值