js获取项目路径
1.html中引入jquery.url.js
2.获取项目路径的js方法
function getContextPath() {
var contextPath = "";
var host = jQuery.url.attr('host');
var protocol = jQuery.url.attr('protocol');
var port = jQuery.url.attr('port');
var path = jQuery.url.attr('path');
if (port == null) {
contextPath = protocol + '://' + host + '/' + path.split('/')[1];
} else {
contextPath = protocol + '://' + host + ':' + port + '/' + path.split('/')[1];
}
return contextPath;
}