window.location.href=location.origin+"/apreizspring/teammember"
apreizspring是我的项目名称。我想使用pagecontext
替换它。任何人都可以为我提供解决方案吗?
答案 0 :(得分:3)
在Javascript文件中:
window.location.href = requestContextPath + "/teammember"
可以说,您的javascript文件名为temp.js
在jsp中:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<script>
var requestContextPath = '${pageContext.request.contextPath}';
</script>
<script type='text/javascript' src = 'temp.js'></script>