tomcat 设置了虚拟目录 但为什么图片各CSS还是要用绝对路径才能正确识别?

来源:百度知道 编辑:UC知道 时间:2024/06/21 05:47:22
tomcat 设置了虚拟目录 但为什么图片各CSS还是要用绝对路径才能正确识别?

我在D:\Java\Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost下创建了topscien.xml
里面添加了这样一句:
<Context docBase="D:\Java\Apache Software Foundation\Tomcat 6.0\webapps\topscien" path="/topscien" reloadable="true">
</Context>

我用http://localhost:8080/topscien/访问时,CSS样式表全部不能正常加载,图片也显示不了
我的CSS都放在了D:\Java\Apache Software Foundation\Tomcat 6.0\webapps\topscien\style里面
加载用这样的语句:<link href="style/common.css" type="text/css" rel="stylesheet"/>
<link href="../style/common.css" type="text/css" rel="stylesheet"/>两种都不行

请高手解答,急!

你的那个地址编译后就成了http://localhost:8080/style/common.csshttp://localhost:8080/common.css
当然不对啦
用绝对路径就ok啦