dflmg

在jsp页面顶上面定义

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

然后JavaScript里面获取

<script type="text/javascript">
        var baseUrl="<%=basePath%>";
</script>

获取的url例如:

request.getScheme() = "http"
request.getServerName() = "localhost"
request.getServerPort() = "8080"
request.getContextPath() = "wms-web-enterprise"
baseUrl = "http://localhost:8080/wms-web-enterprise/"

 

分类:

技术点:

相关文章:

  • 2022-01-07
  • 2021-11-30
  • 2021-11-29
  • 2021-07-19
  • 2022-12-23
  • 2021-06-09
猜你喜欢
  • 2021-06-20
  • 2021-09-04
  • 2022-12-23
  • 2022-02-07
  • 2021-12-08
  • 2021-11-27
相关资源
相似解决方案