关于JAVA生成HTML静态页,在前一家公司也写过一些,但是好久没有用,也有些遗忘了,比如关于路径,就有点不清楚具体用那个类。
这次由于公司的网站需要每天更新一个专题活动,破不得已,只好写一个动态生成页。以下做个记录,以备日后参考:
JAVA页面
/**
* 生成HTML页面
*/
  public void hotread(){
    String path = ServletActionContext.getServletContext().getRealPath("/");
    String realPath = path+fileName+".html";
    File file=new File(realPath);
    try{
      byte tag_bytes[] = content2.getBytes();
      FileOutputStream out    = new FileOutputStream(file);
      out.write(tag_bytes);
      out.close();
    }catch(Exception e){
      e.printStackTrace();
    }
  }