contextPath1 [Javascript] context path 가져오는 방법 1. window.location.pathname 이용하는 방법 (비추) // 1. split 사용하는 방법 const pathArray = window.location.pathname.split('/'); const contextPath = pathArray[1]; console.log(contextPath); // 2. substring 사용하는 방법 const contextPath = window.location.pathname.substring(0, window.location.pathname.indexOf("/",2)); console.log(contextPath); => contextPath가 '/' 일 경우에 원하는 결과를 얻지 못할 수 있다. 따라서 2번 방식을 추천한다. 2. sessio.. 2023. 6. 23. 이전 1 다음 반응형