struts 引用外部css失效

我的目录是
webroot/css/xx.css
webroot/web-info/page/xx.jsp

jsp被映射为http://localhost/project/xx.acton

我在jsp中使用绝对路径
加上
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

但是并没用引用上。怎么回事呢?


换成

先给你普及一下绝对路径和相对路径的知识吧,绝对路径是从域名开始往后算的,比如你的action路径:
http://localhost/project/xx.action
它的绝对路径是/project/xx.action
所以说你如果要使用绝对路径的话应该这样

因为你页面上使用了base标签

如果要用相对路径,可以这样