请教生成静态页面的方法

meixue 2007-05-10 04:08:27
看到很多网站都可以把文章生成静态页面,不知道现在生成静态网站的方法有几种?大家推荐说说看.我们开发用的是WEBWORK和HIBERNATE,SPRING.数据存储用oracle数据库
...全文
192 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
koma_wind 2007-09-29
  • 打赏
  • 举报
回复
以前做过,你可以参考一下 仅供参考啊

/**
* 传入模板文件路径,返回模板Html代码
* @param templatePath
* @return
* @throws IOException
*/
public String getTemplateContent(String templatePath) throws IOException{
String templateContent="";
try{
FileInputStream fileinputstream = new FileInputStream(templatePath);//读取模板文件内容
int lenght = fileinputstream.available();
byte bytes[] = new byte[lenght];
fileinputstream.read(bytes);
fileinputstream.close();
templateContent = new String(bytes,"utf-8");
}catch(Exception ex){
templateContent = "";
throw new IOException("没有发现模板文件");
}
return templateContent;
}
/**
* 替换模板中的标记符号,生成html文件,非通用??
* @param info
* @param menu
* @param htmlPath
* @param className
* @return
*/
public boolean createIndexHtml(String title,String info,String htmlPath){
boolean result = false;
try {
String rootdir = "";//这里是应用服务器的路径
String templateFilePath = rootdir + "\\article\\template\\articleIndexTemplate.htm";
String templateContent = getTemplateContent(templateFilePath);
templateContent = templateContent.replaceAll("$html_title",title);
templateContent = templateContent.replaceAll("$html_info",info);
FileOutputStream fileoutputstream = new FileOutputStream(htmlPath);
byte tag_bytes[] = templateContent.getBytes("utf-8");
fileoutputstream.write(tag_bytes);
fileoutputstream.close();
result = true;
}catch(Exception ex){
ex.printStackTrace();
result = false;
}
return result;
}
fffddd 2007-09-25
  • 打赏
  • 举报
回复
freemarker
zhangjg2124 2007-09-25
  • 打赏
  • 举报
回复
freemarker模板就可以
soulh5 2007-09-24
  • 打赏
  • 举报
回复
有没有能实现的代码呀,我看到没有能成功地
Eric_Yu_Nupt 2007-05-10
  • 打赏
  • 举报
回复
做成文件生成~数据库记录地址。
Sherlock_Holmes 2007-05-10
  • 打赏
  • 举报
回复
freemarker

81,092

社区成员

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

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