转自:http://www.cnblogs.com/Herist/archive/2011/04/10/1977944.html
/** * returns the current http session object * * @return session */ @Override public HttpSession getSession() { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); HttpSession contextSess = attr == null ? session : attr.getRequest().getSession(true); return contextSess; }