js獲取項目路徑問題:
//獲取當前網址,如: http://localhost:8080/uimcardprj/share/meun.jsp
var curPath=window.document.location.href;//獲取主機地址之後的目錄,如: uimcardprj/share/meun.jsp
var pathName=window.document.location.pathname;
var pos=curPath.indexOf(pathName);
//獲取主機地址,如: http://localhost:80
var localhostPaht=curPath.substring(0,pos);
//獲取帶"/"的項目名,如:/uimcardprj
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
js調用中,a方法需要使用b方法中的參數:
定義一個全局變量c,將b參數的值賦給c,在a方法中可以使用b的值
jsp獲取js傳遞url中參數:
可以在
<%
String name = request.getParameter("name");
%>