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

问题描述

如果我在Controller中使用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 by a 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()会清除所有会话属性还是仅对使用它的控制器起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 10:43