关于静态页面生成问题。简单。

fys249931556 2008-06-05 06:59:07
据说有个freemarker的这个东西可以生成静态页面。
请问有没有例子,或者用法? 给个连接就行。。谢谢各位了。
...全文
183 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fys249931556 2008-06-09
  • 打赏
  • 举报
回复
谢谢各位了。有空自己再找找看吧。
yooooyiiiiiiiiii 2008-06-08
  • 打赏
  • 举报
回复
例子:
使用FreeMarker生成Html静态文件(实例)
http://www.jscud.com/srun/news/viewhtml/2_2005_4/36.htm

FreeMarker官网也有例子
http://www.freemarker.org/index.html
fys249931556 2008-06-08
  • 打赏
  • 举报
回复
还是不行 。。。
难道没有办法么 ?
fys249931556 2008-06-07
  • 打赏
  • 举报
回复
帖子加100分,希望各位帮帮忙。
fys249931556 2008-06-07
  • 打赏
  • 举报
回复
5楼的仁兄能不能在讲解下,实在是不会用。
谢谢各位回答啊。
i_saw_you 2008-06-07
  • 打赏
  • 举报
回复
"d:/dzh/ddd.html"改成"d://dzh//ddd.html"试试
goldlive_8888 2008-06-06
  • 打赏
  • 举报
回复
不难,一般大型网站用这个。给你讲一下原理。
正确的说,freemarker只是完成了其中重要的一步。
生成静态的页面要有两个重要的参数,一个是生成页面的模板(一个简单的页面,将要显示的数据位置用freemarker标签站位),生成页面的位置(物理位置,如c:\tomtcat\...)。
使用freemarker是因为freemarker有一个方法,整个方法的参数有两个,一个是模板的地址,一个是要显示的数据(类型为Map),这个方法会返回一个字符串,这是已经生成的页面的内容,你再用文件流以生成页面的位置为参数,将字符串写入文件,这样,所有的操作就完成了。
duzhonghua 2008-06-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lbqlbq 的回复:]
import java.io.*;
import java.net.*;

public class Tools {
final static Object lock = new Object();

public static void makeHtml(String page, String filePath) {
makeHtml(page, filePath, "UTF-8");
}

public static void makeHtml(String page, String filePath, String chartset) {
synchronized (lock) {
HttpURLConnection huc = null;
BufferedReader br = null;
BufferedWriter bw =…
[/Quote]

怎么调用啊,我传入参数,之后报错咯,是不是这样写啊



public static void main(String[] args) {
Tools.makeHtml("http://community.csdn.net/","d:/dzh/ddd.html");
}
algata 2008-06-06
  • 打赏
  • 举报
回复
顶楼上的 拿来试试看看
lbqlbq 2008-06-06
  • 打赏
  • 举报
回复
import java.io.*;
import java.net.*;

public class Tools {
final static Object lock = new Object();

public static void makeHtml(String page, String filePath) {
makeHtml(page, filePath, "UTF-8");
}

public static void makeHtml(String page, String filePath, String chartset) {
synchronized (lock) {
HttpURLConnection huc = null;
BufferedReader br = null;
BufferedWriter bw = null;
try {
huc = (HttpURLConnection) new URL(page).openConnection();
System.setProperty("sun.net.client.defaultConnectTimeout",
"30000");
System
.setProperty("sun.net.client.defaultReadTimeout",
"30000");
huc.connect();
InputStream stream = huc.getInputStream();
bw = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(filePath), chartset));
br = new BufferedReader(new InputStreamReader(stream, chartset));
String line;
while ((line = br.readLine()) != null) {
if (line.trim().length() > 0) {
bw.write(line);
bw.newLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
br.close();
bw.close();
huc.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

其中:page是要生成静态页面的网页地址
filePath是生成静态页面服务器的物理地址

自己试一下吧,很好用的
fys249931556 2008-06-06
  • 打赏
  • 举报
回复
谢谢楼上回答 。
请问有没有使用方法,或者例子让我参考一下。
真的很希望解决这个问题,困惑我很久了,分不够可以再加的。谢谢了。
fys249931556 2008-06-05
  • 打赏
  • 举报
回复
又是没人人回答。
难道这个静态页面的一直都是难题么 ?
fys249931556 2008-06-05
  • 打赏
  • 举报
回复
怎么老是没有人回答??

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧