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