文章出處
文章列表
本文用于記錄使用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();
文章列表
全站熱搜