我想在超时等于 5s 时重定向到另一个 url。
我拥有的代码:
private void timeout(RoutingContext handler) {
vertx.setPeriodic(5000, new Handler<Long>() {
@Override
public void handle(Long aLong) {
System.out.println("Session expired : " + aLong);
handler.response().putHeader("location","/logout").setStatusCode(302).end();
}
});
}
我得到的错误是:
java.lang.IllegalStateException: Response has already been written"