FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写
FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用程序
虽然FreeMarker具有一些编程的能力,但通常由Java程序准备要显示的数据,由FreeMarker生成页面,通过模板显示准备的数据.
public
void
createFtl(Map
<
String, Object
>
req)
{
try
{
Configuration cfg = new Configuration();
// - Templates are stoted in the WEB-INF/templates directory of the
// Web app.
String tempate = FileConstent.PrePath + "/tempates/";
String destPath = tempate +"index/www.bt285.cn_index.html";
String destPathSpider = tempate +"index/www.bt285.cn_index_spider.html";
// new File(destPath).deleteOnExit();
// new File(destPathSpider).deleteOnExit();
cfg.setDirectoryForTemplateLoading(new File(tempate));
Template tIndex = getTemplate(cfg,
"index/http://www.bt285.cn_index.ftl",Locale.ENGLISH,Constent.DefaultEncodIng);
Template tIndexSpider = getTemplate(cfg,
"index/http://www.bt285.cn_index_spider.ftl",Locale.ENGLISH,Constent.DefaultEncodIng);
doWirte(tIndex,destPath,req);
doWirte(tIndexSpider,destPathSpider,req);
} catch (Exception e)
{
e.printStackTrace();
}
}
public
void
doWirte(Template t,String path,Map
<
String, Object
>
req)
{
try
{
//BufferedOutputStream bw = null;
// FileOutputStream outStream = new FileOutputStream(path);
//BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream,Constent.DefaultEncodIng));
BufferedWriter out = new BufferedWriter(new FileWriter(path));
// Merge the data-model and the template
t.setEncoding(Constent.DefaultEncodIng);
t.process(req,out);
} catch (Exception e)
{
e.printStackTrace();
}
}
private
WNewsDAO
<
WNews
>
newsDAO;
private
WCommentsDAO commentsDAO;
public
static
Template getTemplate(Configuration cfg,String name,Locale locale,String decode)
throws
IOException
{
return cfg.getTemplate(name);
}
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"
>
<
HTML
dir
=ltr
xml:lang
="zh-CN"
xmlns ="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=UTF-8"
/>
<
link
media
=screen
href
="/js/application.css"
type
=text/css
rel
=Stylesheet
>
<
link
media
=screen
href
="/js/default.css"
type
=text/css
rel
=Stylesheet
>
<
title
>
BT下载|BT电影|BT软件|BT285.cn
</
title
>
<
meta
name
="keywords"
content
="BT下载|BT电影|BT软件|BT285.cn"
/>
<
meta
name
="description"
content
="BT285.cn 为大家网友提供BT下载,BT电影还有BT软件,BT联盟等一系列BT服务."
/>
<
meta
name
="robots"
content
="all"
/>
<
meta
http-equiv
="cache-control"
content
="no-cache"
>
<
meta
http-equiv
="pragma"
content
="no-cache"
>
<
meta
http-equiv
="expires"
content
="0"
>
</
head
>
<
body
>
<
div
class
="wrapper"
>
<
div
class
="header"
>
<
#include
"../head/www.bt285.cn_head.html"
>
<
form
action
="http://www.baidu.com/baidu"
target
="_blank"
>
<
table
bgcolor
="#FFFFFF"
><
tr
><
td
>
<
input
name
=tn
type
=hidden
value
=baidu
>
<
a
href
="http://www.baidu.com/"
><
img
src
="http://img.baidu.com/img/logo-80px.gif"
alt
="Baidu"
align
="bottom"
border
="0"
></
a
>
<
input
type
=text
name
=word
size
=30
>
<
input
type
="submit"
value
="百度搜索"
>
</
td
></
tr
></
table
>
</
form
>
</
div
>
<
div
class
="outer"
>
<
div
class
="inner"
>
<
div
class
="left"
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/yazhou"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
亚洲BT下载
</
a
></
h2
></
font
>
</
div
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/btjinglin"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
bt精灵下载
</
a
></
h2
></
font
>
</
div
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/tibetisxizang"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
西藏(tibetisxizang)专题
</
a
></
h2
></
font
>
</
div
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/dapian"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
大片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list77 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/war"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
战争片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list83 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
欧美BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list76 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/sci"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
科幻片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list81 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/quyi"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
曲艺BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list91 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
欧美BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list10 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
欧美BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list11 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
欧美BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list12 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
</
div
>
<!--
end left
-->
<
div
class
="center"
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/sitcom"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
连续剧BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list85 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/art"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
文艺片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list82 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/fear"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
恐怖片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list84 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/zhongyi"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
综艺BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list87 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/pingshu"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
评书BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list92 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list69 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list90 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list95 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
</
div
>
<!--
end middle
-->
<
div
class
="right"
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/movie"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
影视BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list75 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/love"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
爱情片BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list80 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/jap"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
日剧BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list86 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/sport"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
体育BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list89 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/xiangsheng"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
相声BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list93 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list96 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list97 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
<
div
style
="margin-left:3px; border: 2px solid #CCDEaF; background:#FaFaFa;"
>
<
div
style
="margin-left:60px;"
><
font
size
=+1
><
h2
><
a
href
="http://www.bt285.cn/other"
style
="color:black;font-size: 13pt;text-decoration: none;"
>
其他BT下载
</
a
></
h2
></
font
>
</
div
>
<
#list
list99 as p
>
<
div
>
<
span
class
="index-title-word"
>
<
a
href
="http://www.bt285.cn/content.php?id=${p.strId}"
target
="_blank"
title
="${p.title}"
>
${p.title}
</
a
>
</
span
>
</
div
>
</
#list
>
</
div
>
</
div
>
<!--
end rigth
-->
<
div
class
="clear"
></
div
>
</
div
>
</
div
>
<
div
id
=footer
style
="BORDER-TOP: #47749e 2px solid; MaRGIN-TOP: 10px; COLOR: #006699; PaDDING-TOP: 5px; TEXT-aLIGN: center"
>
<
div
style
="MaRGIN-TOP: 5px"
>
<
#include
"../link/www.bt285.cn_link.html"
>
<
#include
"../foot/www.bt285.cn_foot.html"
>
</
div
>
</
div
>
</
body
>
</
html
>