FreeMarkerConfigurer使用TemplateDirectiveModel时获取request、session

使用:

ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();

HttpServletRequest request = attr.getRequest();

然后在web.xml中增加如下配置

<listener>

   <listener-class>

       org.springframework.web.context.request.RequestContextListener

   </listener-class>

</listener>




你可能感兴趣的:(FreeMarkerConfigurer使用TemplateDirectiveModel时获取request、session)