本文介绍了SessionStatus object.setComplete() 是清除所有会话属性还是仅适用于使用它的控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在控制器中使用 SessionStatus object.setComplete(),我不清楚这一点,它是清除 Webapp 的所有会话数据还是只清除由使用@SessionAttributes 的特定控制器?

I am not clear about this if I use SessionStatus object.setComplete() in a Controller, does it clears all the session data of the Webapp or just clears the session data saved bya particular controller in which @SessionAttributes is used?

推荐答案

SessionStatus#setComplete() JavaDoc 对方法的目的非常清楚:

SessionStatus#setComplete() JavaDoc is pretty clear about the method's purpose:

/**
 * Mark the current handler's session processing as complete, allowing for
 * cleanup of session attributes.
 */

这会清除通过@SessionAttribute 注册的当前处理程序的会话属性.这与servlet的HttpSession#invalidate()完全不同:

This clears the current handler's session attributes registered via @SessionAttribute. This is completely different from servlet's HttpSession#invalidate():

/**
 * Invalidates this session then unbinds any objects bound to it.
 */

这实际上完全破坏了用户会话.

This one actually destroys the user session completely.

这篇关于SessionStatus object.setComplete() 是清除所有会话属性还是仅适用于使用它的控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 17:30