如何获取JavaScript和Java应用的完整路径?
- 内容介绍
- 文章标签
- 相关推荐
本文共计80个文字,预计阅读时间需要1分钟。
例如:[代码][JavaScript]代码:java: String path=request.getContextPath(); String basePath=request.getScheme() + :// + request.getServerName() + : + request.getServerPort() + path + /; ****
比如:localhost:8080/app1.[代码][JavaScript]代码
java: String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; /************************************? javascript: var localObj = window.location; var contextPath = localObj.pathname.split("/")[1]; var basePath = localObj.protocol+"//"+localObj.host+"/"+contextPath; var server_context=basePath;
本文共计80个文字,预计阅读时间需要1分钟。
例如:[代码][JavaScript]代码:java: String path=request.getContextPath(); String basePath=request.getScheme() + :// + request.getServerName() + : + request.getServerPort() + path + /; ****
比如:localhost:8080/app1.[代码][JavaScript]代码
java: String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; /************************************? javascript: var localObj = window.location; var contextPath = localObj.pathname.split("/")[1]; var basePath = localObj.protocol+"//"+localObj.host+"/"+contextPath; var server_context=basePath;

