프로젝트에서는 종종 프로젝트의 절대적인 경로를 가져와야하므로 파일을 업로드하고 다운로드 할 수 있습니다. JS는 우회해야하지만 방법을 제공합니다. 코드는 다음과 같습니다.
함수 getRealPath () {// http : // localhost : 8083/myproj/view/my.jsp var curwwwpath = window.document.location.href; // 호스트 주소 다음과 같은 호스트 주소 다음과 같은 디렉토리를 가져옵니다 : myProj/view/my.jsp var pathName = window.document.location.pathname; var pos = curwwwpath.indexof (pathname); // http : // localhost : 8083 var localhostpaht = curwwwpath.substring (0, pos); // :/myProj var projectName = pathName.SubString (0, pathName.substr (1) .indexof ( '/')+1)과 같은 프로젝트 이름을 가져옵니다. // http : // localhost : 8083/myproj var realpath = localhostpaht+projectname; 경고 (realPath); }