`
ssydxa219
  • 浏览: 609061 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

freemarker rem

 
阅读更多

1. 获取cookie.
   <#assign cookies = request.getCookies()>
       <#list cookies as cookie>
             <#if cookie.name = "userName">
                   ${cookie.name}
                   ${cookie.value}
               </#if>
      </#list>

2. 获取request.
<#if Request["shoppingCart"]?exists>
<#assign shoppingCart = Request["shoppingCart"]>

3.session.
<#if Session["shoppingCart"]?exists>
<#assign shoppingCart = Session["shoppingCart"]>
action中:
HttpServletRequest request = ServletActionContext.getRequest();
    request.getSession().setAttribute("pathtu", filepath);
ftl页面:
${Session["pathtu"]?default("Session")}
读取堆栈:
<#assign code=((stack.findString("#parameters['code']"))?default('001'))/>

在后台给request,session设置值即可在ftl页面使用的,如:

public ModelAndView employeeItemKpi(HttpServletRequest request,String employeeName) {

    request.setAttribute("name", "your value");

    HttpSession session = request.getSession();
    session.setAttribute("isAll", isAll);

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics