JSTL删除所有会话属性 [英] JSTL Remove ALL session attributes

查看:51
本文介绍了JSTL删除所有会话属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Google搜索,发现可以使用以下方法删除会话属性:

I have been googling and found that I can remove a session attribute using:

<c:remove var="foo" />

我想要的是从JSP中清除所有会话属性,如下所示:

What I want is to clear all session attributes from a JSP, something like this:

<c:forEach  var="item" items="${sessionScope}">
    <c:remove var="${item }" scope="session"/>
</c:forEach>    

问题是上面的代码给了我这个警告

The problem is that the code from above gives me this warning

c:删除不支持运行时表达式

而且我无法查看放置代码的JSP.

And I can't view the JSP where I put the code.

有可能吗?做这样的事情是一种好习惯吗?

Is it possible? Is it a good practice to do something like this?

推荐答案

因为您正在"item"中进行迭代,并且在循环内进行迭代,因此您尝试删除.

最好仅在Java中而不是在JSP中执行此逻辑

Better do this logic in java only rather than JSP

这篇关于JSTL删除所有会话属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆