FreeMarke

1  FreeMarker 不会语法模板中使用JSP标签 <servlet>       <servlet-name>JspSupportServlet</servlet-name>       <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>       <load-on-startup>1</load-on-startup>   </servlet>   <#assign  c =JspTaglibs["/WEB-INF/tld/c.tld"] >   使用方法 <@c.import url="http://127.0.0.1:8080/menu.do"/>

2 .取Application范围的对象 <#if Application.myApplicationAttribute?exists>        ${Application.myApplicationAttribute}    </#if>    

 取session范围的对象 <#if Session.mySessionAttribute?exists>        ${Session.mySessionAttribute}    </#if>    

取request范围的对象 <#if Request.myRequestAttribute?exists>         ${Request.myRequestAttribute}    </#if>    

取request parameter范围的对象 <#if Parameters.myParameter?exists>        ${Parameters.myParameter}    </#if>    

取context parameter范围的对象 ${stack.findValue('#myContextParam')}      

 web.xml  

<servlet>        

<servlet-name>freemarker</servlet-name>       

  <servlet-class>             freemarker.ext.servlet.FreemarkerServlet         </servlet-class>         <init-param>         

    <param-name>TemplatePath</param-name>           

  <param-value>/</param-value>      

   </init-param>      

   <init-param>          

   <param-name>NoCache</param-name>            

 <param-value>true</param-value>   

      </init-param>      

   <init-param>          

   <param-name>ContentType</param-name>         

    <param-value>text/html</param-value>    

     </init-param>

        <init-param>          

   <param-name>template_update_delay</param-name>             <param-value>0</param-value>        

</init-param>   

      <init-param>     

        <param-name>default_encoding</param-name>           

  <param-value>GBK</param-value>  

       </init-param>       

  <init-param>    

         <param-name>locale</param-name>            

 <param-value>en_ZH</param-value>       

  </init-param>      

   <init-param>            

 <param-name>number_format</param-name>   

          <param-value>0.##########</param-value>        

 </init-param>         <load-on-startup>1</load-on-startup>  

   </servlet>   <servlet-mapping>     <servlet-name>action</servlet-name>  

   <url-pattern>*.do</url-pattern>   </servlet-mapping>  

 <servlet-mapping>         <servlet-name>freemarker</servlet-name>     

    <url-pattern>*.ftl</url-pattern>   </servlet-mapping>   <session-config>  

      <session-timeout>10</session-timeout>    </session-config>    

 <#include "../common/style.jsp">  

<#list templist as vo> 

${vo.vcity}  </#list >    

 <#macro greet person color> //定义宏   <font size="+2" color="${color}">Hello ${person}!</font> </#macro>   

<#local y = "test">

<#assign user = "Joe Hider">  全局变量      

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值