1: 使用spring freemarker 3 起的话,可以使用
@Autowired
private HttpServletRequest request;
2:
使用: ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
在web.xml添加监听器:
<span style="white-space:pre"></span><pre name="code" class="html"><span style="white-space:pre"> </span><listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>