struts2 访问页面的请求如下:
<dirurl>/consumption/queryAction.action</dirurl>admin/adminlist.jsp中的路径显示图片:
<img src="../images/lgo_0hm_129x36.on.gif" width="129" height="33">其中 images和admin目录同级。点击请求进去页面看不到图片,在myclipse的preview中可以看到换成:
<img src="images/lgo_0hm_129x36.on.gif" width="129" height="33">点击请求进去页面可以看到图片,在myclipse的preview中却看不到请问一下怎么解决
<dirurl>/consumption/queryAction.action</dirurl>admin/adminlist.jsp中的路径显示图片:
<img src="../images/lgo_0hm_129x36.on.gif" width="129" height="33">其中 images和admin目录同级。点击请求进去页面看不到图片,在myclipse的preview中可以看到换成:
<img src="images/lgo_0hm_129x36.on.gif" width="129" height="33">点击请求进去页面可以看到图片,在myclipse的preview中却看不到请问一下怎么解决
执行起来没问题就可以了啊。相对路径,你的位置不同肯定就可以显示不到啊。myclipse不怎么用。
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
然后在head中
<base href="<%=basePath%>">
这样,它全部的路径不是从根路径开始了吗?
我希望两边都能看到
<%
String path = request.getContextPath();
String path1 = request.getServletPath();
int i = path1.lastIndexOf("/");
String path2 = path1.substring(0,i);
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + path2 + "/";
request.setAttribute("basepath",basePath);
%> <base href="<%=request.getAttribute("basepath")%>"/> 谢谢大家的帮助