String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
打印出:
getContextPath /aaa
getScheme://getServerName:getServerPort/ http://localhost:8082/aaa/
项目名 --- aaa --- getContextPath()
协议名 --- http --- getScheme()
服务器地址 --- localhost --- getServerName()
端口号 --- 8082 --- getServerPort()