简体   繁体   English

JSF / Xpages 如何清除会话范围?

[英]JSF / Xpages how to clear sessionscopes?

I want to clear the current sessionscopes in my xpages application and reload them again.我想清除我的 xpages 应用程序中的当前会话范围并重新加载它们。 I have tried:我努力了:

public Map<String, Object> sesScope;
this.sesScope = JSFUtil.getSessionScope();

clearMap(sesScope);

private void clearMap(Map<String, Object> map ){ // Get iterator for the keys
    String methodName = new Object(){}.getClass().getEnclosingMethod().getName();
    utils.printToConsole(this.getClass().getSimpleName().toString() + " " + methodName);
    utils.printToConsole("-------before removing------");
    utils.printToConsole(map.toString());

    Set keyset = map.keySet();
    Iterator itr = keyset.iterator();
    while (itr.hasNext()) {
        itr.next();
        itr.remove();
    }

    utils.printToConsole("--------After removing-------");
    utils.printToConsole(map.toString());
}

Somehow I can not simply say sesScope.clear() since that would result in an error:不知何故,我不能简单地说 sesScope.clear() 因为那样会导致错误:

java.lang.UnsupportedOperationException at com.sun.faces.context.BaseContextMap.clear(ExternalContextImpl.java:392) java.lang.UnsupportedOperationException 在 com.sun.faces.context.BaseContextMap.clear(ExternalContextImpl.java:392)

How do I clear the sessionscope properly?如何正确清除会话范围?

I do this to clear sessionScope:我这样做是为了清除 sessionScope:

for (final String key : JSFUtil.getSessionScope().keySet()) {
    JSFUtil.getSessionScope().remove(key);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM