0
我目前使用Spring和AngularJS。Spring + AngularJS(HTML)獲取上下文路徑?
到目前爲止沒有問題顯示我的index.html
使用Spring,像這樣
有什麼辦法,我可以得到我的.html
我的上下文路徑?或者我應該把我的index
作爲index.jsp
?
我目前使用Spring和AngularJS。Spring + AngularJS(HTML)獲取上下文路徑?
到目前爲止沒有問題顯示我的index.html
使用Spring,像這樣
有什麼辦法,我可以得到我的.html
我的上下文路徑?或者我應該把我的index
作爲index.jsp
?
正如你所說,你應該呈現爲一個JSP以訪問的contextPath:
:${pageContext.request.contextPath}
如果你想堅持純HTML也許你可以從使用Javascript URL中提取它
function getContextPath() {
return window.location.pathname.substring(0, window.location.pathname.indexOf("/",2));
}
console.log(getContextPath());
是的,我希望其他選項,但如果他們存在。 – Incognito
JS替代方法現在可以完成。謝謝! – Incognito
有沒有簡單的方法將getContextPath()的結果追加到href鏈接? – zygimantus