request.getSession(true)和request.getSession(false)的區別
request.getSession(true):若存在會話則返回該會話,否則新建一個會話。
request.getSession(false):若存在會話則返回該會話,否則返回NULL
當向Session中存取登錄信息時,一般建議:HttpSession session =request.getSession();
當從Session中獲取登錄信息時,一般建議:HttpSession session =request.getSession(false);