我现在用的是首页jstl标签判断EL是否为空,为空就直接跳向Action。现在网站还小,但是首页数据大了估计就很慢了。在网上查到有首页静态化这个功能,然后凌晨自动刷新?
这种方法怎么实现?

解决方案 »

  1.   


    /*
     * Create by: zhouwenfan 
     * Email:[email protected]
     * Time: 2010-09-08
     */package com.lucene.mysql;import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.methods.GetMethod;public class CreateStaticPage {


    public static void main(String[] args) {
        
    try{
        
           HttpClient client = new HttpClient();
          
          
           //client.getHostConfiguration().setHost("http://www.baidu.com");
          
           //读取要生成静态页面的页面
           GetMethod  get = new GetMethod("http://www.baidu.com");
          
           client.executeMethod(get);
          
           String s = get.getResponseBodyAsString();
          
           //生成的静态页面存放的位置及名称
           BufferedWriter bw = new BufferedWriter(new FileWriter(new File("d://baidu.html")));
          
           bw.write(s);
           bw.close();
           get.releaseConnection();
          
         }catch (Exception ex ){
        
     System.out.print(ex);
    }
    } }
      

  2.   

    用到的jarcommons-codec-1.3.jarcommons-httpclient-3.0.jarcommons-logging-1.1.jar