當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。