2015-09-28 62 views

回答

3

正如你所說,你應該呈現爲一個JSP以訪問的contextPath:

${pageContext.request.contextPath} 

如果你想堅持純HTML也許你可以從使用Javascript URL中提取它

function getContextPath() { 
    return window.location.pathname.substring(0, window.location.pathname.indexOf("/",2)); 
} 
console.log(getContextPath()); 
+0

是的,我希望其他選項,但如果他們存在。 – Incognito

+0

JS替代方法現在可以完成。謝謝! – Incognito

+0

有沒有簡單的方法將getContextPath()的結果追加到href鏈接? – zygimantus