java 能做动态生静态的网站吗?能 怎么做

解决方案 »

  1.   

    能不能给个用freeer动生静态的例子
      

  2.   

    当然可以啦,方法很多了,终究就是生成静态html
      

  3.   

    1 java.io 读html模板文件
    2 构造新的网页字符串
    3 java.io 写到一个新的文件里
    写文件例子
    FileOutputStream afile=new FileOutputStream(path+"/test.htm");
    PrintWriter pw=new PrintWriter(afile);
    pw.println(orgtxt);
    pw.close();
      

  4.   

    我做过一个新闻发布系统。
    读取固定的模板和数据库的数据,生成html页面模板可以由美工去制作,使用人员负责录入数据,点击生成。1 java.io 读html模板文件 
    2 将模板中自定义的标签用数据库的内容给替换掉  (核心标签的制作)
    3 java.io 写到一个新的文件里 
    标签TagSupport可以去看看有关的资料。
      

  5.   

    去看 freeMarker的文档吧,虽然是英文的,不过写的非常细
    我这里只有很简单的几个。有兴趣你可以参考。http://www.java2000.net/f280
      

  6.   


    简单原理:HTML 文件 template.htm
      <body>
        This is my HTML page. <br>
        author:#author#
        内容:#content#
      </body>JSP文件<% String filePath = request.getRealPath("/")+"template.htm";
     out.print(filePath);
     String templateContent=""; FileInputStream fileinputstream = new FileInputStream(filePath);//读取模块文件
     int lenght = fileinputstream.available();
     byte bytes[] = new byte[lenght];
     fileinputstream.read(bytes);
     fileinputstream.close();
     templateContent = new String(bytes); String title = "";
     String editer = "作者";
     String content = "这里是文章内容";
     templateContent=templateContent.replaceAll("#title#",title);
     templateContent=templateContent.replaceAll("#author#",editer);//替换掉模块中相应的地方
     templateContent=templateContent.replaceAll("#content#",content);
     
     
     String fileame = "new.html"; fileame = request.getRealPath("/")+fileame;//生成的html文件保存路径 out.print(templateContent);
     FileOutputStream fileoutputstream = new FileOutputStream(fileame);//建立文件输出流
     byte tag_bytes[] = templateContent.getBytes();
     fileoutputstream.write(tag_bytes);
     fileoutputstream.close();%>
      

  7.   

    freeer,velocity,xslt,Taperstry等等等等
    都可以做的,自己选吧