2015-09-28 72 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