您的位置:首页 > 产品设计 > UI/UE

【Java】request.getContextPath()备忘

2017-10-24 17:10 148 查看
String path = request.getContextPath();  

String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;  

request.getScheme()可以返回当前页面使用的协议;默认返回http,SSL时返回https;

request.getServerName()可以返回当前页面所在的服务器的名字;

request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是项目在服务器上发布的 端口,或者在本地tomcat容器运行时发布的端口,我用的是8081;

request.getContextPath()可以返回当前页面所在的应用的名字;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: