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





  • 相关阅读:
    poj 1611 The Suspects
    POJ 2236 Wireless Network
    POJ 1703 Find them, Catch them
    poj 1733 Parity game
    hdu 1598 find the most comfortable road
    cmake的使用二:链接第三方静态库
    线段树基础
    迪杰斯特拉算法
    Floyd详解
    STL中的set使用方法详细
  • 原文地址:https://www.cnblogs.com/YuyuanNo1/p/9808729.html
Copyright © 2020-2023  润新知