1、jfinalcomjfinalcoreController.java
/**
* Render with view use default type Render configured in JFinalConfig
*/
public void render(String view) {
render = renderManager.getRenderFactory().getRender(view);
}
2、
public class JFinalConfig extends com.jfinal.config.JFinalConfig
public void configConstant(Constants constants) {
if(log.isInfoEnabled()) log.info("configConstant 视图Beetl设置");
ToolBeetl.brf.config();
constants.setRenderFactory(ToolBeetl.brf);
ToolBeetl.regiseter();
}
3、
import org.beetl.core.BeetlKit;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.ext.jfinal3.JFinal3BeetlRenderFactory;
public static final JFinal3BeetlRenderFactory brf = new JFinal3BeetlRenderFactory();
/**
* 模板扩展
*/
public static GroupTemplate regiseter(){
DataBase dataBase = ToolDataBase.getDbMap(ConstantInit.db_dataSource_main);
String db_type = dataBase.getType();
Map<String, Object> sharedVars = new HashMap<String, Object>();
sharedVars.put("db_type", db_type);
if(log.isDebugEnabled()) log.debug("注册全局web视图模板解析");
GroupTemplate mainGT = brf.groupTemplate;
if(mainGT == null){
JFinal3BeetlRenderFactory brfTemp = new JFinal3BeetlRenderFactory();
brfTemp.config();
mainGT = brfTemp.groupTemplate;
}
mainGT.registerFunction("authUrl", new AuthUrl());
mainGT.registerFunction("escapeHtml", new EscapeHtml());
mainGT.registerFunction("unEscapeHtml", new UnEscapeHtml());
mainGT.registerFunction("i18nFormat", new I18nFormat());
// mainGT.registerFunction("sqlEncode", new SqlEncode());
mainGT.registerFunction("unEscapeHtml", new UnEscapeHtml());
mainGT.registerTag("sql", SqlTag.class);
mainGT.setSharedVars(sharedVars);
if(log.isDebugEnabled()) log.debug("注册全局BeetlKit模板解析");
GroupTemplate kitGT = BeetlKit.gt;
kitGT.registerFunction("authUrl", new AuthUrl());
kitGT.registerFunction("escapeHtml", new EscapeHtml());
kitGT.registerFunction("unEscapeHtml", new UnEscapeHtml());
kitGT.registerFunction("i18nFormat", new I18nFormat());
// kitGT.registerFunction("sqlEncode", new SqlEncode());
kitGT.registerTag("sql", SqlTag.class);
kitGT.setSharedVars(sharedVars);
return mainGT;
}