之前用外部js,获取不到${pageContext.request.contextPath}的实际值,会发生乱码事件
所以外部js(User.js)中这样写
window.onload = function () {
document.getElementById("back").onclick = back;
function back() {
window.location.href = document.getElementById("PageContext").value+"/getAllUsersServlet";
}
}
jsp中
<script src="js/User.js"></script>
<div class="form-group" style="text-align: center">
<input class="btn btn-primary" type="submit" value="提交"/>
<input class="btn btn-default" type="reset" value="重置"/>
<input class="btn btn-default" type="button" value="返回" id="back"/>
<input id="PageContext" type="hidden" value="${pageContext.request.contextPath}" />
</div>
|
|