SpringMvc 整合Freemarker后,ftl页面怎么获取httpSession
2个回答
展开全部
springmvc的配置文件中对freemarker配置如下:
<bean
id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property
name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"
/>
<property name="suffix" value=".html" />
<property
name="contentType" value="text/html;charset=utf-8" />
<property
name="exposeRequestAttributes" value="true" />
<property
name="exposeSessionAttributes" value="true" />
<property
name="exposeSpringMacroHelpers" value="true" />
<!--
此变量值为pageContext.request, 页面使用方法:rc.contextPath -->
<property
name="requestContextAttribute" value="rc" />
</bean>
是这样方式:
${Session["user"]}
<bean
id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property
name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"
/>
<property name="suffix" value=".html" />
<property
name="contentType" value="text/html;charset=utf-8" />
<property
name="exposeRequestAttributes" value="true" />
<property
name="exposeSessionAttributes" value="true" />
<property
name="exposeSpringMacroHelpers" value="true" />
<!--
此变量值为pageContext.request, 页面使用方法:rc.contextPath -->
<property
name="requestContextAttribute" value="rc" />
</bean>
是这样方式:
${Session["user"]}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询