JavaScript中如何设置或获取basePath变量?

更新于
2026-09-30 19:16:21
1阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计146个文字,预计阅读时间需要1分钟。

JavaScript中如何设置或获取basePath变量?

主要用来自替代表示jsp中经常使用的basePath+/**/,减少相对路径的使用,并增加basePath*+*项目上下文访问路径,例如:/myproject*+*@type {string}*+*/var projectPath=window.*+*;

JavaScript中如何设置或获取basePath变量?

主要用来替代jsp中经常使用的basePath

/* * 减少相对路径而添加的basePath * 主要用来替代jsp中经常使用的basePath * */ /** * 项目上下文访问路径 * 如:/myproject * @type {string} */ var projectPath = window.location.pathname == 'null'?'':window.location.pathname.substring(0,window.location.pathname.indexOf('/',1)); /** * 服务器地址 如 : localhost:8080 * @type {string|Array|*|string|Array. } */ var serverPath = window.location.origin; /** * 便于服务器资源访问的basePath * 如:localhost:8080/myproject * @type {string} */ var basePath = serverPath + projectPath;

本文共计146个文字,预计阅读时间需要1分钟。

JavaScript中如何设置或获取basePath变量?

主要用来自替代表示jsp中经常使用的basePath+/**/,减少相对路径的使用,并增加basePath*+*项目上下文访问路径,例如:/myproject*+*@type {string}*+*/var projectPath=window.*+*;

JavaScript中如何设置或获取basePath变量?

主要用来替代jsp中经常使用的basePath

/* * 减少相对路径而添加的basePath * 主要用来替代jsp中经常使用的basePath * */ /** * 项目上下文访问路径 * 如:/myproject * @type {string} */ var projectPath = window.location.pathname == 'null'?'':window.location.pathname.substring(0,window.location.pathname.indexOf('/',1)); /** * 服务器地址 如 : localhost:8080 * @type {string|Array|*|string|Array. } */ var serverPath = window.location.origin; /** * 便于服务器资源访问的basePath * 如:localhost:8080/myproject * @type {string} */ var basePath = serverPath + projectPath;