JSP path setting
<%
String path=request.getContextPath();
String basePath=request.getScheme()+"://"
+ request.getServerName()+":" +request.getServerPort()
+ path+"/";
%>
<base href="<%=basePath%>">
<%@ page language="java" pageEncoding="GBK"
contentType="text/html;charset=gbk" isELIgnored="false"%>
<%
String path = request.getContextPath();
// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
// 将 "项目路径basePath" 放入pageContext中,待以后用EL表达式读出。
pageContext.setAttribute("basePath", basePath);
%>