当前位置: 首页>>代码示例>>Java>>正文


Java TemplateExceptionHandler类代码示例

本文整理汇总了Java中freemarker.template.TemplateExceptionHandler的典型用法代码示例。如果您正苦于以下问题:Java TemplateExceptionHandler类的具体用法?Java TemplateExceptionHandler怎么用?Java TemplateExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TemplateExceptionHandler类属于freemarker.template包,在下文中一共展示了TemplateExceptionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
public void render(String modelType) throws IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setClassLoaderForTemplateLoading(SimpleModel.class.getClassLoader(), "/");
    if (!outDir.getParentFile().exists())
        outDir.getParentFile().mkdirs();
    String modelTypeName = modelType.substring(0, 1).toUpperCase() + modelType.substring(1);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("packageName", packageName);
    params.put("models", models);
    writeFile(packageName, modelTypeName, getTemplate(cfg, modelType), params);

    for (SimpleModel model : models) {
        if (model.isRender()) {
            params = new HashMap<>();
            params.put("model", model);
            writeFile(model.getPackageName(), model.getName(), getModelTemplate(cfg), params);
        }
    }
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:22,代码来源:Context.java

示例2: prepareConfiguration

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
private static Configuration prepareConfiguration() {
  Configuration result = new Configuration(Configuration.VERSION_2_3_26);

  result.setNumberFormat("computer");
  result.setDefaultEncoding(StandardCharsets.UTF_8.name());
  result.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  result.setLogTemplateExceptions(false);

  return result;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:11,代码来源:TemplateProcessor.java

示例3: init

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
@Override
public void init(ServletConfig servletConfig) throws ServletException {
  this.servletConfig = servletConfig;

  //templateCfg.setClassForTemplateLoading(getClass(), "/");
  Resource baseResource;
  try {
    baseResource = Resource.newResource(servletConfig.getInitParameter("resourceBase"));
  } catch (MalformedURLException e) {
    throw new ServletException(e);
  }
  templateCfg.setTemplateLoader(new ResourceTemplateLoader(baseResource));
  templateCfg.setDefaultEncoding("UTF-8");

  // Sets how errors will appear.
  // During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER
  // is better.
  // cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  templateCfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:IndexServlet.java

示例4: init

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
public void init() throws IOException {
    ClassTemplateLoader ctl = new ClassTemplateLoader(Application.class, "/freemarker");
    MultiTemplateLoader mtl = new MultiTemplateLoader(new TemplateLoader[] {ctl});

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setTemplateLoader(mtl);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    Pair<String, Template> clusterResourceQuota = new ImmutablePair<String, Template>("ClusterResourceQuota-ForUser", cfg.getTemplate("ClusterResourceQuota-ForUser.ftlh"));
    Pair<String, Template> bestEffortResourceLimits = new ImmutablePair<String, Template>("LimitRange-BestEffortResourceLimits", cfg.getTemplate("LimitRange-BestEffortResourceLimits.ftlh"));
    Pair<String, Template> burstableResourceLimits = new ImmutablePair<String, Template>("LimitRange-BurstableResourceLimits", cfg.getTemplate("LimitRange-BurstableResourceLimits.ftlh"));
    Pair<String, Template> maxImageCounts = new ImmutablePair<String, Template>("LimitRange-MaxImageCounts", cfg.getTemplate("LimitRange-MaxImageCounts.ftlh"));
    Pair<String, Template> bestEffort = new ImmutablePair<String, Template>("ResourceQuota-BestEffort", cfg.getTemplate("ResourceQuota-BestEffort.ftlh"));
    Pair<String, Template> notTerminatingAndNotBestEffort = new ImmutablePair<String, Template>("ResourceQuota-NotTerminating-And-NotBestEffort",
                                                                              cfg.getTemplate("ResourceQuota-NotTerminating-And-NotBestEffort.ftlh"));
    Pair<String, Template> terminating = new ImmutablePair<String, Template>("ResourceQuota-Terminating", cfg.getTemplate("ResourceQuota-Terminating.ftlh"));

    templates = Arrays.asList(clusterResourceQuota, bestEffortResourceLimits, burstableResourceLimits, maxImageCounts, bestEffort, notTerminatingAndNotBestEffort, terminating);
}
 
开发者ID:garethahealy,项目名称:quota-limits-generator,代码行数:22,代码来源:YamlTemplateProcessor.java

示例5: initializeConfiguration

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
/**
 * Configures freemarker for usage.
 * @return
 * @throws URISyntaxException
 * @throws TemplateNotFoundException
 * @throws MalformedTemplateNameException
 * @throws ParseException
 * @throws IOException
 * @throws TemplateException
 */
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

	Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);
	
	Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();

	customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);

	cfg.setCustomNumberFormats(customNumberFormats);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:32,代码来源:DwFeatureModelSVGGenerator.java

示例6: initializeConfiguration

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
	
	Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
	customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
	
	cfg.setCustomDateFormats(customDateFormats);
	cfg.setDateTimeFormat("@simle");

	Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:22,代码来源:DwFeatureModelOverviewGenerator.java

示例7: getConfigurationByClass

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
/**
 * 根据根路径的类,获取配置文件
 * @author nan.li
 * @param paramClass
 * @param prefix
 * @return
 */
public static Configuration getConfigurationByClass(Class<?> paramClass, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassForTemplateLoading(paramClass, prefix);
        //等价于下面这种方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:28,代码来源:FreeMkKit.java

示例8: getConfigurationByClassLoader

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
public static Configuration getConfigurationByClassLoader(ClassLoader classLoader, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassLoaderForTemplateLoading(classLoader, prefix);
        //等价于下面这种方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:21,代码来源:FreeMkKit.java

示例9: getConfigurationByDirectory

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
/**
 * 根据模板的路径,获取一个配置文件
 * @author [email protected]
 * @param templateLoadingPath
 * @return
 */
public static Configuration getConfigurationByDirectory(File templateLoadingPath)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        
        //以下这两种设置方式是等价的
        //            configuration.setDirectoryForTemplateLoading(templateLoadingPath);
        configuration.setTemplateLoader(new FileTemplateLoader(templateLoadingPath));
        
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:29,代码来源:FreeMkKit.java

示例10: JoomlaHugoConverter

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
public JoomlaHugoConverter(NastyContentChecker nastyContentChecker,
                           JdbcTemplate template, String pathToOutput, String dbExtension,
                           boolean buildTags) throws IOException {

    this.dbExtension = dbExtension;

    this.nastyContentChecker = nastyContentChecker;
    this.template = template;
    this.pathToOutput = pathToOutput;
    this.buildTags = buildTags;

    Configuration cfg = new Configuration(Configuration.getVersion());
    cfg.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(), "/");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    categoryTemplate = cfg.getTemplate("categoryPage.toml.ftl");
    contentTemplate = cfg.getTemplate("defaultPage.toml.ftl");

    buildTags();
}
 
开发者ID:davetcc,项目名称:hugojoomla,代码行数:23,代码来源:JoomlaHugoConverter.java

示例11: init

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
private void init() {
	if (inited) {
		return;
	}
	lock.lock();
	try {
		if (!inited) {
			cfg = new Configuration(Configuration.VERSION_2_3_25);
			cfg.setDefaultEncoding(encode);
			cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			cfg.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(), tmplPath);
		}
	} finally {
		lock.unlock();
	}
}
 
开发者ID:kanven,项目名称:schedule,代码行数:17,代码来源:TmplMarker.java

示例12: TemplateService

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
public TemplateService() {

		String templatePath = new File("").getAbsolutePath();
		System.out.println("Using template path '" + templatePath + "'.");
		
		try {
			config = new Configuration(Configuration.VERSION_2_3_25);
			config.setDirectoryForTemplateLoading(new File(templatePath));
			config.setDefaultEncoding("UTF-8");
			config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			config.setLogTemplateExceptions(false);
		} catch (IOException e) {
			throw new FileLibraryException(e);
		}
		
	}
 
开发者ID:dvanherbergen,项目名称:robotframework-filelibrary,代码行数:17,代码来源:TemplateService.java

示例13: SchemaMaker

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
/**
 * @param onTable
 */
public SchemaMaker(String tenant, String module, TenantOperation mode, String previousVersion, String rmbVersion){
  if(SchemaMaker.cfg == null){
    //do this ONLY ONCE
    SchemaMaker.cfg = new Configuration(new Version(2, 3, 26));
    // Where do we load the templates from:
    cfg.setClassForTemplateLoading(SchemaMaker.class, "/templates/db_scripts");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  }
  this.tenant = tenant;
  this.module = module;
  this.mode = mode;
  this.previousVersion = previousVersion;
  this.rmbVersion = rmbVersion;
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:20,代码来源:SchemaMaker.java

示例14: __doViewInit

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
@Override
protected void __doViewInit(IWebMvc owner) {
    super.__doViewInit(owner);
    // 初始化Freemarker模板引擎配置
    if (__freemarkerConfig == null) {
        __freemarkerConfig = new Configuration(Configuration.VERSION_2_3_22);
        __freemarkerConfig.setDefaultEncoding(owner.getModuleCfg().getDefaultCharsetEncoding());
        __freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
        //
        List<TemplateLoader> _tmpLoaders = new ArrayList<TemplateLoader>();
        try {
            if (__baseViewPath.startsWith("/WEB-INF")) {
                _tmpLoaders.add(new FileTemplateLoader(new File(RuntimeUtils.getRootPath(), StringUtils.substringAfter(__baseViewPath, "/WEB-INF/"))));
            } else {
                _tmpLoaders.add(new FileTemplateLoader(new File(__baseViewPath)));
            }
            //
            __freemarkerConfig.setTemplateLoader(new MultiTemplateLoader(_tmpLoaders.toArray(new TemplateLoader[_tmpLoaders.size()])));
        } catch (IOException e) {
            throw new Error(RuntimeUtils.unwrapThrow(e));
        }
    }
}
 
开发者ID:suninformation,项目名称:ymate-platform-v2,代码行数:24,代码来源:FreemarkerView.java

示例15: createConfiguration

import freemarker.template.TemplateExceptionHandler; //导入依赖的package包/类
Configuration createConfiguration() throws IOException {
        // Create your Configuration instance, and specify if up to what FreeMarker
// version (here 2.3.22) do you want to apply the fixes that are not 100%
// backward-compatible. See the Configuration JavaDoc for details.
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);

// Specify the source where the template files come from. Here I set a
// plain directory for it, but non-file-system sources are possible too:
        cfg.setDirectoryForTemplateLoading(new File("/"));

// Set the preferred charset template files are stored in. UTF-8 is
// a good choice in most applications:
        cfg.setDefaultEncoding("UTF-8");

// Sets how errors will appear.
// During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

        cfg.setTemplateLoader(new ClassTemplateLoader());

        return cfg;
    }
 
开发者ID:albertonavarro,项目名称:nifty-flow,代码行数:23,代码来源:FreemarkerConfiguration.java


注:本文中的freemarker.template.TemplateExceptionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。