获取服务器路径的方式 【记录】

JSP页面获取服务器路径的方式

1.basePath方式

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

在url加入<%=basePath%>如:http://192.168.66.66:8089/xinfang/

2.直接请求服务器路径

${pageContext.request.contextPath}

 

服务端获取服务器路径的方式

//获取远程服务器IP和端口
String serverIp=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();

http://localhost:80/images/ocrtemp_1.png

获取本机IP地址

InetAddress address = InetAddress.getLocalHost();
String hostAddress = address.getHostAddress();

  192.168.66.66

SpringBoot 

window.location.origin

 

 

posted @ 2018-07-24 11:05  yinder  阅读(506)  评论(0编辑  收藏  举报