我做了一个简单的网站与登录页面,一切正常,除了当用户点击浏览器中的返回按钮,前一页显示注销后。
我已经尝试跟踪会话,但没有成功,有什么建议吗?ps:我更喜欢在服务器端编程上实现这一点。
谢谢
这是我的重定向url过滤器,如果有的话,这可能就是问题所在。
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session= request.getSession(false);
if(request.getRequestURI().compareToIgnoreCase("/login.jsp")!=0&&
request.getRequestURI().compareToIgnoreCase("/")!=0)
{
if (session!=null &&!session.isNew())
{
chain.doFilter(req, res);
}
else
{
response.sendRedirect(request.getContextPath()+"/login.jsp");
}
}
else
{
chain.doFilter(req, res);
}
}发布于 2012-02-12 13:57:18
我能想到的两种快速方法:
window.history.back(0) = window.location
< body onunload="javascript:history.go(1)“>
发布于 2017-07-20 19:21:30
通过使用javascript,如果您有两个页面page1和page2和(page1重定向至page2),并且您想要限制用户返回page1,只需将此代码放在page1。
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
function disableBack() {
window.history.forward()
}
window.onload = disableBack();
window.onpageshow = function (evt) {
if (evt.persisted)
disableBack()
}
});
</script>https://stackoverflow.com/questions/9246722
复制相似问题