由于是使用spring mvc来做项目,因此脱离了HttpServletRequest作为参数,不能够直接使用request,要想使用request可以使用下面的方法: 在web点xml中配置一个监听 view plainprint? org.springframework.web.context.request.RequestContextListener 之后就可以在程序使用了