码迷,mamicode.com
首页 > 其他好文 > 详细

FreeMarker应用

时间:2015-01-12 18:57:35      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

<#import "../common/main.ftl" as page> <#import  "../common/pager.ftl" as my> <#include "../common/constant.ftl" /> <@page.main type="" title=""> //给公共模板main.ftl中type,title属性赋值

<style type="text/css">

</style> <script>

</script>

<form action="${(domainPath)!}/jfEvent/findMarketList.mxd" method="post">     <input type="hidden" name="channelId" value="${(channelId)!}">     <input type="hidden" name="categoryId" value="${(categoryId)!}">     <input type="hidden" name="lowScore" value="${(lowScore)!}">     <input type="hidden" name="highScore" value="${(highScore)!}">     <#if lists ??>       <#assign index=0 />       <#list lists as list>         <#assign index=index+1/>         <a href="${(domainPath)!}/jfEvent/queryItemInfo.mxd?id=${(list.eventId)!‘‘}" target="_blank"><img src="${(page.domainImagePath)}/${(list.image)!‘‘}"></a><         ${(list.name)!‘‘}         ${(list.score)!}         ${(list.price)!‘‘}      </#list> <@my.pager listpage = pagination/> //给分页模板pager.ftl中listpage属性赋值 </form>

</@page.main>

main.ftl: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title>${(title)!}</title>     <link rel="stylesheet" type="text/css" href="${(domainPath)!}/resources/css/base.css" />     <link rel="stylesheet" type="text/css" href="${(domainPath)!}/resources/css/homepage.css" />     <link rel="stylesheet" type="text/css" href="${(domainPath)!}/resources/css/public.css" />     <link rel="stylesheet" type="text/css" href="${(domainPath)!}/resources/css/auction.css" />     <#--<script type="text/javascript" src="${(domainPath)!}/resources/js/jquery.js"></script>-->     <script type="text/javascript" src="${(domainPath)!}/resources/js/jquery-1.8.3.js"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/js/jquery.validate.js"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/js/jquery.form.js"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/js/Ajax.js"></script>     <link rel="stylesheet" type="text/css" href="http://www.minxindai.com/static/css/jbox.css" />     <script type="text/javascript" src="http://www.minxindai.com/static/js/jquery.jBox-2.3.min.js"></script>     <script type="text/javascript" src="http://www.minxindai.com/static/js/jquery.jBox-zh-CN.js"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/js/focus.js"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/js/global.js"></script>     <script type="text/javascript" src="${((domainPath)!)!}/resources/js/PCASClass.js" charset="utf-8"></script>     <script type="text/javascript" src="${(domainPath)!}/resources/DatePicker/WdatePicker.js"></script> </head> <body>     <#include "head.ftl">     <#if type=="0">         <div class="content-bg-white pt10">             <#nested>         </div>     <#elseif type=="1">         <div class="content-bg-white pt10">             <div class="wrap">                  <@channel onCur=onCur navigater=navigater></@channel>                  <#nested>             </div>         </div>     </#if>     <#include "foot.ftl"> </body> </html> </#macro> <#macro channel onCur="" navigater=""> <div class="navgation-box clear">     <a href="${(domainPath)!}/find.mxd">         <dl class="s1 <#if onCur=="1">cur</#if>" >             <dt></dt>             <dd></dd>         </dl>     </a> </div> <!--navgation-box--end--> <#if navigater="1"> <div class="bread-nav-wp">     <a href="/jfEvent/getHomePage.mxd">首页</a>     <#if navigater ??>         <span>&gt;</span>         <a href="${(navigater.url)!}">${(navigater.name)!}</a>     </#if> </div> </#if> </#macro> <script> function find(){     window.location.href = "${(domainPath)!}/find.mxd"; } </script>

head.ftl:                 <a href="${(domainHomePath)!}/?m=user&c=login" class="orange-link fl">登录</a>                 <span class="space colccc fl">|</span>                 <a href="${(domainHomePath)!}/?m=user&c=reg"class="orange-link fl">注册</a>                 <#else>                 <span class="orange-link fl">${username},您好</span>

foot.ftl:             <div class="foot_saoma fl mr30">                 <p class="fl f13">微信二维码<br>                     <img src=""></p>             </div>

            <div class="fl pl30">                 <div class="foot_contact_bottom pt68">                     <p class="foot_contact_bottom_telfont col515151 f16">客服热线:</p>                     <a class="coldc3a24 f20" href="#"></a>                 </div>             </div> <p>版权所有&nbsp;&nbsp;保留所有权利&nbsp;&nbsp;京ICP备13005404号-2</p>

pager.ftl: <#macro pager listpage =""> <input name="pageNo" id="pageNo" type="hidden" value="1"> <input name="pageSize" id="pageSize" type="hidden" value="${(pageSize)!9}"> <div class="clear page_zf">     <div class="page_fen">     <#if listpage??>             <#--[总数:${(listpage.totalCount)!}条]&nbsp;&nbsp;-->             <#--<a href="javascript:gotopage(1);">首页&nbsp;&nbsp;</a>-->             <#--${(listpage.totalPage)!}-->             <#if listpage.totalPage < 10>                 <#if listpage.pageNo<=1>                     <a href="javascript:void(0);" class="uppage_btn btn_stop arrow-left"><i></i>上一页</a>                 <#else>                     <a href="javascript:gotopage(${(listpage.pageNo-1)});" class="uppage_btn arrow-left"><i></i>上一页</a>                 </#if>                 <ul class="page_fen_ul">                 <#list 1..listpage.totalPage as n>                      <li class="page_fen_li"><a class="page_fen_a <#if listpage.pageNo==n > page_num_spe</#if>" href="javascript:gotopage(${(n)});">${n}</a></li>                 </#list>                 </ul>                 <#if (listpage.pageNo>=listpage.totalPage) >                     <a href="javascript:void(0);" class="downpage_btn btn_stop arrow-right">下一页<i></i></a>                 <#else >                     <a href="javascript:gotopage(${(listpage.pageNo+1)});" class="downpage_btn arrow-right">下一页<i></i></a>                 </#if>             <#else>                 <#if listpage.pageNo<=1>                     <a href="javascript:void(0);" class="uppage_btn btn_stop arrow-left"><i></i>上一页</a>                 <#else>                     <a href="javascript:gotopage(${(listpage.pageNo-1)});" class="uppage_btn arrow-left"><i></i>上一页</a>                 </#if>

                <#if listpage.pageNo <=4 >                     <ul class="page_fen_ul">                         <#list 1..5 as n>                             <li class="page_fen_li"><a class="page_fen_a <#if listpage.pageNo==n > page_num_spe</#if>" href="javascript:gotopage(${(n)});">${n}</a></li>                         </#list>                             <li class="page_fen_li">...</li>                             <li class="page_fen_li"><a class="page_fen_a" href="javascript:gotopage(${listpage.totalPage});">末页</a></li>                     </ul>                 <#elseif (listpage.pageNo > 4) && (listpage.pageNo <= listpage.totalPage-4) >                     <ul class="page_fen_ul">                         <li class="page_fen_li"><a class="page_fen_a" href="javascript:gotopage(1);">首页</a></li>                         <li class="page_fen_li">...</li>

                        <#list listpage.pageNo-2..listpage.pageNo+2 as n>                             <li class="page_fen_li"><a class="page_fen_a <#if listpage.pageNo==n > page_num_spe</#if>" href="javascript:gotopage(${(n)});">${n}</a></li>                         </#list>

                        <li class="page_fen_li">...</li>                         <li class="page_fen_li"><a class="page_fen_a" href="javascript:gotopage(${listpage.totalPage});">末页</a></li>                     </ul>                 <#elseif (listpage.pageNo > (listpage.totalPage-5)) >                     <ul class="page_fen_ul">                         <li class="page_fen_li"><a class="page_fen_a" href="javascript:gotopage(1);">首页</a></li>                         <li class="page_fen_li">...</li>                         <#list listpage.totalPage-5..listpage.totalPage as n>                             <li class="page_fen_li"><a class="page_fen_a <#if listpage.pageNo==n > page_num_spe</#if>" href="javascript:gotopage(${(n)});">${n}</a></li>                         </#list>

                    </ul>                 </#if>                 <#if (listpage.pageNo>=listpage.totalPage) >                     <a href="javascript:void(0);" class="downpage_btn btn_stop arrow-right">下一页<i></i></a>                 <#else >                     <a href="javascript:gotopage(${(listpage.pageNo+1)});" class="downpage_btn arrow-right">下一页<i></i></a>                 </#if>             </#if>     </#if>     </div> </div> <script>     function gotopage(pageNo){         if(pageNo>=1&&pageNo<=${(listpage.totalPage)!}){             document.getElementById("pageNo").value = pageNo;             document.forms[0].submit();         }     } </script> </#macro>

 

FreeMarker应用

标签:

原文地址:http://www.cnblogs.com/zifashaonian10000/p/4218866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!