• jfinal如何设置使用哪种模板引擎(视图)


    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;
    }





  • 相关阅读:
    关于UIView的userInteractionEnabled属性
    ASIHTTPRequest 一款强大的HTTP包装开源项目
    Cocoa中NSString到NSDate的处理
    完美解决ios4与ios5输入框随键盘移动问题
    iOS中使用c函数快速获取一个目录所占的空间大小
    修改图片尺寸
    让一个UIImageView响应点击事件
    怎样判断ios app 第一次启动
    [EGORefreshTableHeaderView]手动启动下拉更新的方法
    单例模式
  • 原文地址:https://www.cnblogs.com/YuyuanNo1/p/9808729.html
Copyright © 2020-2023  润新知