質問

I am creating a TreeMap bean. I want to pass this around in the session scope. However, I need to reset/clear this TreeMap bean.

This is how I am declaring my bean:

<jsp:useBean id="foo" class="java.util.TreeMap" scope="session"/>

Any ideas on how to clear/reset the usebean (and keep using the same id) would be appreciated.

役に立ちましたか?

解決

If you use c:set JSTL tag and pass in null, the variable will be removed. Another way to remove it to use c:remove

So

<c:remove var="foo" scope="session"/>

or

<c:set var="foo" scope="session" value="nullVar"/>

where nullVar evaluates to null

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top