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);
}
下面介绍访问应用程序各范围属性的语法示例:
Application范围假定Application范围有一个属性 myApplicationAttribute :
java 代码
<#if Application.myApplicationAttribute?exists>
${Application.myApplicationAttribute}
#if>
或java 代码
<@s.property value="%{#application.myApplicationAttribute}" />
Session范围假定会话范围内有一个属性mySessionAttribute:
java 代码
<#if Session.mySessionAttribute?exists>
${Session.mySessionAttribute}
#if>
或java 代码
<@s.property value="%{#session.mySessionAttribute}" />
Request范围假定请求范围有一个属性myRequestAttribute
java 代码
<#if Request.myRequestAttribute?exists>
${Request.myRequestAttribute}
#if>
或
java 代码
<@s.property value="%{#request.myRequestAttribute}" />
Request参数假定请求参数myParameter
java 代码
<#if Parameters.myParameter?exists>
${Parameters.myParameter}
#if>
or
java 代码
<@s.property value="%{#parameters.myParameter}" />
Context参数假定框架上下文有一参数myContextParam
java 代码
${stack.findValue('#myContextParam')}
或
java 代码
<@s.property value="%{#myContextParam}" />