1:配置
web.xmlorg.springframework.web.context.request.RequestContextListener
2在代码任何地方
import org.springframework.web.context.request.RequestContextHolder;import org.springframework.web.context.request.ServletRequestAttributes;HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();