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);
}