?? velocityfactory.java
字號:
package com.easyjf.blog.logic;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import com.easyjf.web.Globals;
public class VelocityFactory {
private static final Logger logger = (Logger) Logger.getLogger(VelocityFactory.class);
private static VelocityEngine ve;
private VelocityFactory()
{
}
private static VelocityEngine getVelocityEngine()
{
if(ve==null)doInit();
return ve;
}
private static void doInit()
{
Properties p = new Properties();
ve=new VelocityEngine();
//System.out.println(ve==null);
//System.out.println(Globals.APP_BASE_DIR+BaseSiteConfig.getInstance().getTemplatePath());
p.setProperty("file.resource.loader.path", Globals.APP_BASE_DIR+Globals.DEFAULT_TEMPLATE_PATH);
try
{
ve.init(p);
}
catch(Exception e)
{
System.out.println("初努化錯誤:"+e);
}
}
public static Template getTemplate(String fileName)
{
return getTemplate(fileName,"utf-8");
}
public static Template getTemplate(String fileName,String encoding)
{
Template template = null;
try{
template=getVelocityEngine().getTemplate(fileName,encoding);
}
catch(Exception e)
{
logger.error(e.getClass().toString()+e);
}
return template;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -