色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

通用大型網(wǎng)站頁面靜態(tài)化解決方案

多個文件服務(wù)器讀寫,這里可采用SMB協(xié)議
頁面靜態(tài)化,可采用freemarker開源框架
如果考慮到大量的讀寫請求,則將請求分布式或采用調(diào)度的辦法來解決
第一點我們首先應(yīng)該考慮文件服務(wù)器與靜態(tài)頁面的映射關(guān)系,即什么文件應(yīng)該讀寫到哪臺服務(wù)器,這個關(guān)系最簡單的辦法是隨機映射,然后將映射關(guān)系保存到數(shù)據(jù)庫中即可,SMB常用的操作代碼如下:
復(fù)制代碼 代碼如下:
    public static boolean exists(String filepath,String username,String pwd) throws Exception
    {
    SmbFile file = new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
try{
    return file.exists();
}catch(Exception ex){
    return false;
}
    }

public static boolean fileRename(String filepath,String newFilename,String username,String pwd)
    {
    try{
         SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
         if(f.isFile()){
     String str=filepath.substring(0,filepath.lastIndexOf("/"));
     str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
     f.renameTo(new SmbFile(str));
         }else if(f.isDirectory()){
         String str=filepath.substring(0,filepath.length()-1);
         str=filepath.substring(0,str.lastIndexOf("/"));
         str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
         f.renameTo(new SmbFile(str));              
         }
     return true;
    }catch(Exception ex){
        return false;
    }
    }

public static void mkdir(String dir,String username,String pwd)
{
try{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+dir);
     if(!f.exists())
f.mkdir();
}catch(Exception ex)
{
}
}

public static void mkfile(String filepath,String username,String pwd)
{
try
{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
     if(!f.exists())
f.createNewFile();
}catch(Exception ex)
{
}
}

public static void mkfile(String filepath,String username,String pwd,String content)
{
try
{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
     if(!f.exists())
f.createNewFile();
writeFile(filepath,content,username,pwd);
}catch(Exception ex)
{
}
}

public static boolean isdir(String filepath,String username,String pwd) throws Exception
{
String dir="smb://"+username+":"+pwd+"@"+filepath;
SmbFile f=new SmbFile(dir);
return f.isDirectory();
}

第二點,頁面靜態(tài)化可由freemarker生成,freemarker的使用比較簡單,我這里不再 主站蜘蛛池模板: 桃源县| 醴陵市| 岢岚县| 长寿区| 翁牛特旗| 赤城县| 江陵县| 顺昌县| 远安县| 佛教| 丰城市| 临泽县| 海兴县| 天峻县| 廊坊市| 临朐县| 象山县| 衡阳县| 兴义市| 长春市| 新密市| 吴川市| 遵化市| 吉木萨尔县| 双城市| 泾源县| 东台市| 镇安县| 读书| 志丹县| 无为县| 华蓥市| 蒙自县| 娄底市| 阿拉善右旗| 普格县| 永平县| 儋州市| 综艺| 德昌县| 开远市|