请高手进来谈谈关于页面静态化技术,在线等待 小弟完全没做过 只想听听大家的意见注意是真静态 不是URL改变

解决方案 »

  1.   

    好像不同的语言有不同的方式吧,
    比如:JSP不需要了吧;PHP的smarty应该算吧
      

  2.   

    静态还真是麻烦,以前只做过根据模板替换文本,生成静态html文件的。至于列表显示的东西可没弄过,很久没涉及这方面了
      

  3.   

    可以去我的博客看一下,http://blog.ganhui0818.cn/article/jsp/8.htm这篇文章也是转了别人的。我之前做过静态化,是管理员在后台生成相关的静态页面。现在贴出来供参考,请高手指教。
    action中package action;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;import model.MakeHtml;
    import model.ProductManager;
    import model.Sort;import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.actions.DispatchAction;public class MakeHtmlAction extends DispatchAction { //生成首页商品推荐
    public ActionForward tuijianHtml(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    // TODO Auto-generated method stub

    String url=request.getRealPath("/"); 
    String path=request.getContextPath();

    System.out.println("url:"+url);  
    ArrayList arr=ProductManager.tuijianProduct();
    MakeHtml.tuijianHtml(arr,url,path);

    return mapping.findForward("toTuijian");
    }

    }业务逻辑处理:
    public class MakeHtml {
    public static void tuijianHtml(ArrayList arr,String url,String path){
    System.out.println("url--:"+url);
    File f=new File(url+"style\\html\\tuijian.html");
    if(!f.exists()){
    try {
    f.createNewFile();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }else{
    f.delete();
    try {
    f.createNewFile();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    // System.out.println("ffff"+f.getParent()+"8888"+f.getPath());
    try {
    FileOutputStream fos=new FileOutputStream(f);
    PrintStream p=new PrintStream(fos);
    p.print("<table class=\"table\">");
    for(int i=0;i<arr.size();i++){
    if(i%2==0||i==0){
    p.print("<tr>");
    }
    p.print("<td width=\"250\" style=\"font-size: 12px\">");
    ProductInfo product=(ProductInfo)arr.get(i);

    p.print(product.getName()+"<br>");
    p.print("<img src=\""+path+"/upload/"+product.getImage()+"\""+" width=\"120\" height=\"120\"/><br>");
    p.print(product.getDescript()+"<br>");
    p.print("<div style=\"text-decoration: line-through\">市场价:"+product.getPrice()+"</div>");
        p.print("会员价:"+product.getSaleprice()+"<br>");
        p.print("<a href=\""+path+"/detail.jsp?id="+product.getId()+"\">详情</a>&nbsp;&nbsp");
        p.print("<a href=\""+path+"/order.do?method=order&id="+product.getId()+"\">定购</a></br>");
    p.print("</td>");
    if((i+1)%2==0){
    p.print("<tr><td colspan=\"2\"><hr><td></tr></tr>");
    }
    }
    p.print("</table>");
    p.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }
    }仅供参考。。
      

  4.   

    静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成
      

  5.   

    静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成
      

  6.   

    静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成