GWT-Spring Security-会话超时

发布于 2025-01-08 10:29:44 字数 294 浏览 0 评论 0原文

我有一个 GWT + Spring Security Web 应用程序。我试图添加:

<security:session-management invalid-session-url="/X.html"/>

但是,当我尝试测试这一点时。看来我看到了一个:

com.google.gwt.user.client.rpc.InvocationException

消息作为X.html的HTML内容。有人可以建议如何解决这个问题吗?

I have a GWT + Spring Security web app. I was trying to add:

<security:session-management invalid-session-url="/X.html"/>

However, when I try to test this. It seems I see a:

com.google.gwt.user.client.rpc.InvocationException

with message as the HTML content of X.html. Can someone please advise on how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶茶白久 2025-01-15 10:29:44

由于 GWT 通过 Ajax RPC 请求与服务器通信,因此浏览器不会重定向到 X.html。您在服务调用中需要做的是,如果未经授权,则抛出异常,并在 AsyncCallbackvoid onFailure(Throwable catch) 方法中进行处理。

Because GWT communicates with a server via Ajax RPC requests, the browser will not be redirected to X.html. What you need to do in your service calls is throw an exception if they are not authorized and handle in in void onFailure(Throwable caught) method of your AsyncCallback.

别想她 2025-01-15 10:29:44

如果您想重定向到 /X.html ,请尝试:

Window.Location.replace(GWT.getHostPageBaseURL()+"X.html");

但是,如果您想将请求发送到服务器,请使用 RequestBuilder:

String url = GWT.getHostPageBaseURL() + "/X.html";

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

try {
    Request request = builder.sendRequest(null, new RequestCallback() {
    public void onError(Request request, Throwable exception) {
        // invalid request
    }

    public void onResponseReceived(Request request, Response response) {
        if (200 == response.getStatusCode()) {
            // success
        } else {
            // sth went wrong
        }
    }
});
} catch (RequestException e) {
  // couldn't connect to server
}

If you want to redirect to /X.html try:

Window.Location.replace(GWT.getHostPageBaseURL()+"X.html");

However, if you want to send the request to the server use RequestBuilder:

String url = GWT.getHostPageBaseURL() + "/X.html";

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

try {
    Request request = builder.sendRequest(null, new RequestCallback() {
    public void onError(Request request, Throwable exception) {
        // invalid request
    }

    public void onResponseReceived(Request request, Response response) {
        if (200 == response.getStatusCode()) {
            // success
        } else {
            // sth went wrong
        }
    }
});
} catch (RequestException e) {
  // couldn't connect to server
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文