Spring MVC手札
本文用于记录使用Spring MVC中的零散手札
1.在普通java类中获取HttpServletRequest对象
在web.xml的listener节点加入
<listener> <listener-class>org.springframework.web.context.request.RequestContextListener </listener-class> </listener>
//需要使用的地方如下方法获取 HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
注:此文章属懒惰的肥兔原创,版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接
若您觉得这篇文章还不错请点击下右下角的推荐,有了您的支持才能激发作者更大的写作热情,非常感谢。
如有问题,可以通过lzrabbit@126.com联系我。