public HttpSession getSession(boolean create)Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session. If create is false and the request has no valid HttpSession, this method returns null. Parameters: true - to create a new session for this request if necessary; false to return null if there's no current sessionReturns: the HttpSession associated with this request or null if create is false and the request has no valid session
你也可以试一下看看两种用法是否有区别
好象加上true假如以前没有该对象的时候可以创建吧(个人猜想,没有查到资料)
true - to create a new session for this request if necessary; false to return null if there's no current sessionReturns:
the HttpSession associated with this request or null if create is false and the request has no valid session
但实际用起来好像 getSession(true)有时会自动创建一个新的session,而把原来的session替换掉