java - 会话已过期
问题描述
在我的 Web 应用程序中,当会话过期时,我必须再次刷新 (F5) 网页才能继续使用该应用程序,否则,它将返回错误“OOps 出现问题,会话已过期”
我做了这样的事情:
http.sessionManagement()
.maximumSessions(1)
.expiredUrl("/start")
.and().invalidSessionUrl("/start");
应用:
server.port: 8080
但这只有在我刷新网站时才有效,否则它将不起作用有什么建议吗?
解决方案
放置一个 keepalive 脚本,用于重置会话超时,或检查会话是否已过期并自动重定向用户。
var pingFrequency = 30;
// initializes the keep-alive settings
$(function() {
setKeepAliveTimeout();
});
// executes a ping after pingFrequency
function setKeepAliveTimeout() {
setTimeout(keepAlivePing, pingFrequency * 1000);
}
// executes the keepAlivePing, schedules a new ping if required
function keepAlivePing() {
$.get("/keep-alive/ping", function (response) {
if (/* check the response conditions */) {
setKeepAliveTimeout();
}
});
}
推荐阅读
- javascript - React/Redux - 在路由之间切换时内容渲染有延迟
- azure - Azure 上的 Umbraco:找不到模板和 System.Net.Sockets.SocketException
- bash - 使用 sudo 别名启动 Midnight Commander `mc` 并保留路径
- android - 片段未出现在托管活动中
- c# - 在 Xamarin iOS 中打开 url 后是否应该处理 NsUrl?
- mapbox - 使用 Mapbox SDK 6.7 启用 pro Guard 时无法生成构建
- c++ - 静态声明时的c ++复制构造错误
- javascript - 如何使用 socket.io 接收数据?
- .net - Microsoft Bot Framework OAuth 卡返回错误请求
- javascript - 如何创建 Konva-React 上下文菜单