|
頁面靜態化,可采用freemarker開源框架
如果考慮到大量的讀寫請求,則將請求分布式或采用調度的辦法來解決
第一點我們首先應該考慮文件服務器與靜態頁面的映射關系,即什么文件應該讀寫到哪臺服務器,這個關系最簡單的辦法是隨機映射,然后將映射關系保存到數據庫中即可,SMB常用的操作代碼如下:
復制代碼 代碼如下:
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();
}
第二點,頁面靜態化可由freemarker生成,freemarker的使用比較簡單,我這里不再 主站蜘蛛池模板: 察隅县| 潮州市| 城步| 喀喇沁旗| 宁波市| 革吉县| 泊头市| 监利县| 石柱| 海门市| 莆田市| 和静县| 潼关县| 济源市| 滨海县| 东城区| 资源县| 探索| 南城县| 革吉县| 嘉定区| 夏河县| 汉沽区| 即墨市| 香格里拉县| 陵水| 乌兰县| 句容市| 宾川县| 冷水江市| 酉阳| 黑水县| 博罗县| 绥中县| 通海县| 岳池县| 河曲县| 桐柏县| 盐津县| 都江堰市| 临泉县|