问题是,通过重定向请求,Vaadin接收登录页面作为对内部请求的响应。
这似乎有效:
.expiredSessionStrategy(e -> {
final String redirectUrl = e.getRequest().getContextPath() + "/login";
if(SecurityUtils.isFrameworkInternalRequest(e.getRequest())) {
e.getResponse().setHeader("Content-Type", "text/plain");
e.getResponse().getWriter().write("Vaadin-Refresh: " + redirectUrl);
} else {
e.getResponse().sendRedirect(redirectUrl);
}
});
它记录在
连接状态处理程序
public interface ConnectionStateHandler {
/**
* A string that, if found in a non-JSON response to a UIDL request, will
* cause the browser to refresh the page. If followed by a colon, optional
* whitespace, and a URI, causes the browser to synchronously load the URI.
*
* <p>
* This allows, for instance, a servlet filter to redirect the application
* to a custom login page when the session expires. For example:
* </p>
*
* <pre>
* if (sessionExpired) {
* response.setHeader("Content-Type", "text/html");
* response.getWriter().write(myLoginPageHtml + "<!-- Vaadin-Refresh: "
* + request.getContextPath() + " -->");
* }
* </pre>
*/
String UIDL_REFRESH_TOKEN = "Vaadin-Refresh";