生成静态页面技术,现在有两种解决方案(我了解得)
一种是在取数据时候,建立写入流,把动态生成得数据写入预先设置好的html文件里面
例子:http://hi.baidu.com/fei112/blog/item/92f4112e5c2a5d544fc22659.html
二是用freeer这个java开源模板,建议楼主去google下,这个得需要学习下

解决方案 »

  1.   

    有没有freeer生成静态网页的教程.........
      

  2.   

    自己在做网站的时候写个功能,首页的动态页面的地址不对外开发,利用数据流写一个生成静态页面的方法。我真好做个这样一个方法,生成的时候有两种方法,一个是根据url生产,将动态页面的内容写成一个动态文件,将这个静态的文件做首页,自己定时去生成这个文件就可以了,还有一种是用内容生成,比如自己打开动态的首页,然后右键显示源文件,将源文件保存为一个静态的html文件,将此文件作为首页。
      

  3.   

    添加页面。add.jsp
    <%@ page contentType="text/html; charset=utf-8" language="java" pageEncoding="utf-8" %>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
    <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/vi/jsp/viiee_manage/css/style.css"/>
    <script language="javascript" src="http://localhost:8080/vi/js/Base.js"></script>
    <script language="javascript" src="http://localhost:8080/vi/js/FormUtil.js"></script>
    <script type="text/javascript" src="http://localhost:8080/vi/FCKeditor/fckeditor.js"></script> 
    <title>静态包含文件</title>
    </head>
    <body>
       
    <html:form action="/ajax/saveAjaxHtml.htm" method="post">
    <TABLE width="100%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder"> 
      <tr><th height=25 colspan="2" class="tableHeaderText">添加文件</th></tr><TR ALIGN="center"><TD>
    </TD></TR>
      <TR ALIGN="center">
       <tr><td>标题:<input type=text id="name" name="name"/><font color='#FF0000'>*</font></td></tr>
       <tr><td>序号:<input type=text id="sort" name="sort"/></td></tr>  
       <TR><td><input type="radio" name="flag"  id="flag1" value="0" onClick=showUrl()>正文生成<input type="radio" name="flag"  id="flag2" value="1" onClick=showContent()>从url生成</td></TR>     
     <tr><td  id="style1" style="DISPLAY: none">正文:<textarea  name="content" id='content' rows="10" cols="50"></textarea></td></tr>
     <script type="text/javascript">
    var oFCKeditor=new FCKeditor('content');
     oFCKeditor.ReplaceTextarea();
     </script>
     <tr><td id="style2" style="DISPLAY: none">请求的url地址:<input type="text" name="fromurl" id="fromurl"><font color='#FF0000'>*</font></td></tr>
      <tr><td>生成静态文件的位置:<input type="text" name="topath" id="topath"><font color='#FF0000'>*</font></td></tr>
              <tr><td>请求密钥:<input type="text" name="key" id="key"></td></tr>
        <tr><td><input type="submit" name="submit" value="添加" onClick="return check()"></input> 
        <input type="reset"  name="reset" value="重置"></input></td></tr> 
    </tr>   
    </TABLE>  
    </html:form>
    </body>
    </html>
    <script LANGUAGE="JavaScript">
    function showUrl(){
    if (document.ajaxHtmlForm.flag1.checked == true) {
    style1.style.display = "";
    style2.style.display = "none";
    }else{
    style1.style.display = "none";
    style2.style.display = "";
    }
    }
    function showContent(){
    if (document.ajaxHtmlForm.flag2.checked == true) {
    style2.style.display = "";
    style1.style.display = "none";
    }else{
    style2.style.display = "none";
    style1.style.display = "";
    }
    }
    </script>
    <script LANGUAGE="JavaScript">
    function check()
    {
    var name =gid("name");
    var sort =gid("sort");
    var topath =gid("topath");
    var key =gid("key");
     
    if (trim(name.value)=="")
    {
    alert("请输入标题!")
    name.focus()
    name.select()
    return false;
    }
    if (trim(sort.value)=="")
    {
    alert("请输入序号!")
    sort.focus()
    sort.select()
    return false;
    }
    if (trim(topath.value)=="")
    {
    alert("请输入生成静态文件的位置!")
    topath.focus()
    topath.select()
    return false;
    }
    }
    function trim(inputString) {    
                  if (typeof inputString != "string") { return inputString; }
                  var retValue = inputString;
                  var ch = retValue.substring(0, 1);
                  while (ch == " ") { 
              //检查字符串开始部分的空格
                      retValue = retValue.substring(1, retValue.length);
                      ch = retValue.substring(0, 1);
                  }
                  ch = retValue.substring(retValue.length-1, retValue.length);
                  while (ch == " ") {
                     //检查字符串结束部分的空�g e格
                     retValue = retValue.substring(0, retValue.length-1);
                     ch = retValue.substring(retValue.length-1, retValue.length);
                  }
                  while (retValue.indexOf("  ") != -1) { 
             //将文字中间多个相连的空格变为一个空�格
                     retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1,retValue.length); 
                  }
                  return retValue;
               } 
    </script> 
      

  4.   

    保存信息
    public ActionForward saveAjaxHtml(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
    if (!checkLogin(request)) return mapping.findForward("adminlogin");
    AjaxHtmlForm ajaxHtmlForm =(AjaxHtmlForm)form;
    AjaxHtml ajaxHtml=new AjaxHtml();
    ajaxHtml.setCatid(ajaxHtmlForm.getCatid());
    ajaxHtml.setFlag(ajaxHtmlForm.getFlag());
    ajaxHtml.setSort(ajaxHtmlForm.getSort());
    ajaxHtml.setName(ajaxHtmlForm.getName());
    ajaxHtml.setFromurl(ajaxHtmlForm.getFromurl());
    ajaxHtml.setTopath(ajaxHtmlForm.getTopath());
    ajaxHtml.setContent(ajaxHtmlForm.getContent());
    ajaxHtml.setKey(ajaxHtmlForm.getKey());


    try {
    getServices().getAjaxHtmlService().saveAjaxHtml(ajaxHtml);
    } catch (Exception e) {
    e.printStackTrace();
    }
    return mapping.findForward("success");
    }
      

  5.   

    有没有好一点的方法,我用的是SSH构架的,不直接在JSP上面写代码的
      

  6.   

    有些是假的
    可以用urlrewrite掩饰
    http://tuckey.org/urlrewrite/
      

  7.   


    这是两种生成静态页面的技术实现。用freeer更好一些,通过预置模板生成。但是还会有很多其他的问题,比如怎样解决静态页生成的时机问题,如果几分钟一次也不好,长时间了也不好。
    还有怎样解决静态页的动态交互问题,一交互就重新生成,还是制定其他的策略就生成呢,用什么交互呢,交互后用户怎样能第一时间感知,但又不消耗服务器资源呢。
    好多问题,需要思考啊。