struts2中的路徑是根據action確定的,而非jsp的真實路徑確定的,所以使用絕對路徑更好。
在jsp中"/"代表整個站點根路徑,不是web-app根路徑
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
得到的路徑是http://localhost:8080/xxx/
<base href="<%=basePath%>"> 表示所有的連接前面多會加上basepath,從而形成絕對路徑