关于request的小知识

今天在修改bug时,需要下载文件到服务器,再通过服务器上传的网盘。需要拼接一个动态的服务器路径。

。整理如下:

request.getScheme() 返回当前链接使用的协议;比如,一般应用返回http;SSL返回https;

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

request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;

request.getContextPath()可以返回当前页面所在的应用的名字;

request.getRealPath("/")=服务器物理路径

原文地址:https://www.cnblogs.com/Demcia/p/5453838.html