使用:
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = attr.getRequest();
然后在web.xml中增加如下配置
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>