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


Java Configuration.setDefaultEncoding方法代码示例

本文整理汇总了Java中freemarker.template.Configuration.setDefaultEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setDefaultEncoding方法的具体用法?Java Configuration.setDefaultEncoding怎么用?Java Configuration.setDefaultEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在freemarker.template.Configuration的用法示例。


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

示例1: main

import freemarker.template.Configuration; //导入方法依赖的package包/类
public static void main(String[] args) {
    Map<String,Object> tmp = new HashMap<>();
    tmp.put("user","邢天宇");
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
    StringTemplateLoader loader = new StringTemplateLoader();
    loader.putTemplate(NAME,"hello ${user}");
    cfg.setTemplateLoader(loader);
    cfg.setDefaultEncoding("UTF-8");
    try {
        Template template = cfg.getTemplate(NAME);
        StringWriter writer = new StringWriter();
        template.process(tmp,writer);
        System.out.println(writer.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:rpgmakervx,项目名称:slardar,代码行数:19,代码来源:TemplateParser.java

示例2: initConfig

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void initConfig() throws Exception {
    Configuration configuration = new Configuration();
    File file = new File(servletContext.getRealPath("/WEB-INF/layouts"));
    configuration.setDirectoryForTemplateLoading(file);
    configuration.setDefaultEncoding("UTF-8");
    this.template = configuration.getTemplate("email.template");
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:9,代码来源:NoticeService.java

示例3: buildFreemarkerHelper

import freemarker.template.Configuration; //导入方法依赖的package包/类
private FreemarkerHelper buildFreemarkerHelper(File templateBaseDir) {
    Configuration configuration = new Configuration(new Version(2, 3, 0));
    try {
        TemplateLoader templateLoader = new FileTemplateLoader(templateBaseDir);
        configuration.setTemplateLoader(templateLoader);
    } catch (IOException e) {
        throw new GeneratorException("构建模板助手出错:" + e.getMessage());
    }
    configuration.setNumberFormat("###############");
    configuration.setBooleanFormat("true,false");
    configuration.setDefaultEncoding("UTF-8");

    // 自动导入公共文件,用于支持灵活变量
    if (autoIncludeFile.exists()) {
        List<String> autoIncludeList = new ArrayList<>();
        autoIncludeList.add(FREEMARKER_AUTO_INCLUDE_SUFFIX);
        configuration.setAutoIncludes(autoIncludeList);
    }
    return new FreemarkerHelper(configuration);
}
 
开发者ID:sgota,项目名称:tkcg,代码行数:21,代码来源:Generator.java

示例4: templateConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private static Configuration templateConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setLogTemplateExceptions(false);
  try {
    configuration.setSetting("object_wrapper",
        "DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
            + "iterableSupport=true, exposeFields=true)");
  } catch (TemplateException e) {
    e.printStackTrace();
  }
  configuration.setAPIBuiltinEnabled(true);
  configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
      "templates/ccda");
  return configuration;
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:17,代码来源:CCDAExporter.java

示例5: prepareConfiguration

import freemarker.template.Configuration; //导入方法依赖的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

示例6: generateResumeHTML

import freemarker.template.Configuration; //导入方法依赖的package包/类
private String generateResumeHTML(String json, String theme) throws Exception {
    if (!isValidJSON(json)) {
        throw new InvalidJSONException();
    }

    Gson gson = new GsonBuilder().setPrettyPrinting().create();

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setDirectoryForTemplateLoading(new File("themes"));
    cfg.setDefaultEncoding("UTF-8");
    Template temp = cfg.getTemplate(theme + ".html");
    //System.out.println(json);
    Resume resume = gson.fromJson(json, Resume.class);
    resume.getRidOfArraysWithEmptyElements();
    resume.setConfig(config);
    StringWriter htmlStringWriter = new StringWriter();
    temp.process(resume, htmlStringWriter);
    String html = htmlStringWriter.toString();
    return html;
}
 
开发者ID:chenshuiluke,项目名称:jresume,代码行数:21,代码来源:ResumeGenerator.java

示例7: init

import freemarker.template.Configuration; //导入方法依赖的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

示例8: initializeConfiguration

import freemarker.template.Configuration; //导入方法依赖的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

示例9: getConfigurationByClass

import freemarker.template.Configuration; //导入方法依赖的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

示例10: getConfigurationByClassLoader

import freemarker.template.Configuration; //导入方法依赖的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

示例11: getConfigurationByDirectory

import freemarker.template.Configuration; //导入方法依赖的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

示例12: PluginStatusReportViewBuilder

import freemarker.template.Configuration; //导入方法依赖的package包/类
private PluginStatusReportViewBuilder() throws IOException {
    configuration = new Configuration(Configuration.VERSION_2_3_23);
    configuration.setTemplateLoader(new ClassTemplateLoader(getClass(), "/"));
    configuration.setDefaultEncoding("UTF-8");
    configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    configuration.setLogTemplateExceptions(false);
    configuration.setDateTimeFormat("iso");
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:9,代码来源:PluginStatusReportViewBuilder.java

示例13: createTemplateConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private void createTemplateConfiguration(final CompositeConfiguration config, final File templatesPath) {
    templateCfg = new Configuration();
    templateCfg.setDefaultEncoding(config.getString(Keys.RENDER_ENCODING));
    try {
        templateCfg.setDirectoryForTemplateLoading(templatesPath);
    } catch (IOException e) {
        e.printStackTrace();
    }
    templateCfg.setObjectWrapper(new DefaultObjectWrapper());
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:11,代码来源:FreemarkerTemplateEngine.java

示例14: initTemplateEngineCfg

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 * Initializes template engine configuration.
 */
private void initTemplateEngineCfg() {
	configuration = new Configuration();
	configuration.setDefaultEncoding("UTF-8");
	final ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();

	configuration.setServletContextForTemplateLoading(servletContext, "/plugins/" + dirName);
	logger.debug("Initialized template configuration:{}", dirName);
	readLangs();
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:13,代码来源:AbstractPlugin.java

示例15: init

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void init() throws IOException {
  try {
    cfg = new Configuration(Configuration.getVersion());
    cfg.setDirectoryForTemplateLoading(new File(templateLocation));
    cfg.setDefaultEncoding(templateEncoding);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  } catch (IOException e) {
    logger.error("Problem getting rule template location." + e.getMessage());
    throw e;
  }
}
 
开发者ID:edgexfoundry,项目名称:support-rulesengine,代码行数:13,代码来源:RuleCreator.java


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