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

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

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

request.getContextPath()://可以返回当前页面所在的项目的名称名字

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

使用<%=basePath%>加你存放静态文件的位置,如:/static/upload/file/0cad201dd91d49fda68cbe6eccf24984.png

相关文章:

  • 2021-06-14
  • 2022-12-23
  • 2022-01-07
  • 2021-06-06
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
猜你喜欢
  • 2022-12-23
  • 2021-09-27
  • 2021-12-11
  • 2022-12-23
  • 2021-12-03
  • 2021-11-16
相关资源
相似解决方案