本文整理汇总了Java中freemarker.template.Configuration.VERSION_2_3_22属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.VERSION_2_3_22属性的具体用法?Java Configuration.VERSION_2_3_22怎么用?Java Configuration.VERSION_2_3_22使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类freemarker.template.Configuration
的用法示例。
在下文中一共展示了Configuration.VERSION_2_3_22属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
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);
}
}
}
示例2: NexuDeployScriptController
public NexuDeployScriptController() {
try {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setClassForTemplateLoading(getClass(), "/");
this.template = cfg.getTemplate("nexu_deploy.ftl.js", "UTF-8");
} catch (IOException e) {
throw new RuntimeException();
}
}
示例3: render
public void render() throws IOException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "/");
renderPersistence(cfg);
renderContentProvider(cfg);
renderDbHelper(cfg);
renderModels(cfg);
renderMappers(cfg);
}
示例4: init
@PostConstruct
public void init()
{
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setDefaultEncoding("UTF-8");
String templatePath = _config.get("view.freemarker.templates",
"classpath:/templates");
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (templatePath.startsWith("classpath:")) {
String path = templatePath.substring(("classpath:").length());
cfg.setClassLoaderForTemplateLoading(loader, path);
}
else {
throw new UnsupportedOperationException();
}
cfg.setAutoFlush(false);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
_cfg = cfg;
}
示例5: FreemarkerConfiguration
@Inject
public FreemarkerConfiguration() throws Exception {
configuration = new Configuration(Configuration.VERSION_2_3_22);
configuration.setDirectoryForTemplateLoading(new File(TEMPLATES_DIRECTORY));
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
}
示例6: sendMail
@Async
@Override
public void sendMail(String to, Map<String, String> parameters, String template, String subject) {
log.debug("sendMail() - to: " + to);
MimeMessage message = mailSender.createMimeMessage();
try {
String stringDir = MailServiceImpl.class.getResource("/templates/freemarker").getPath();
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setDefaultEncoding("UTF-8");
File dir = new File(stringDir);
cfg.setDirectoryForTemplateLoading(dir);
cfg.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_22));
StringBuffer content = new StringBuffer();
Template temp = cfg.getTemplate(template + ".ftl");
content.append(FreeMarkerTemplateUtils.processTemplateIntoString(temp, parameters));
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(content.toString(), "text/html;charset=\"UTF-8\"");
MimeMultipart multipart = new MimeMultipart("related");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
message.setFrom(new InternetAddress(platformMailConfigurationProperties.getUser().getUsername(), platformMailConfigurationProperties.getUser().getName()));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
mailSender.send(message);
log.info("Message has been sent to: " + to);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: FreeMarkerRender
public FreeMarkerRender(String template, String templateName)
throws IOException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
this.t = new Template(templateName, template, cfg);
}
示例8: renderModelBindings
void renderModelBindings() throws Exception {
if (bindings.size() == 0 && allModels.size() == 0)
return;
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "/");
Template bindingTemplate = cfg.getTemplate("templates/java/binding.ftl");
for (IntentBinding binding : bindings) {
String name = (binding.getPackageName() != null ? binding.getPackageName() + "." : "")
+ binding.getName() + "Binding";
JavaFileObject file = this.processingEnv.getFiler()
.createSourceFile(name, binding.getElement());
Writer writer = file.openWriter();
try {
Map<String, Object> model = new HashMap<>();
model.put("binding", binding);
model.put("cyto", "true".equals(processingEnv.getOptions().get(UI)));
bindingTemplate.process(model, writer);
writer.flush();
} catch (TemplateException err) {
throw new IOException(err);
}
writer.close();
}
if (allModels.size() > 0) {
Element[] elements = new Element[allModels.size()];
int ix = 0;
for (SimpleModel simpleModel : allModels.values()) {
elements[ix++] = simpleModel.getElement();
if (simpleModel instanceof ArrayModel) {
ArrayModel arrayModel = (ArrayModel) simpleModel;
if (arrayModel.getModel() == null)
((ArrayModel) simpleModel).setModel(allModels.get(arrayModel.getModelId()));
continue;
}
if (simpleModel.getParentId() != null && simpleModel.getParent() == null) {
simpleModel.setParent(allModels.get(simpleModel.getParentId()));
simpleModel.getProperties().addAll(simpleModel.getParent().getProperties());
}
for (Property property : simpleModel.getProperties()) {
if (property.getModelId() != null) {
property.setModel(allModels.get(property.getModelId()));
if (property.getModel() == null)
throw new Exception("Model (" + property.getModelId() + ") not found");
}
}
}
String modelTypes = processingEnv.getOptions().get(MODEL_TYPES);
if (modelTypes != null) {
for (String modelType : modelTypes.split(",")) {
String packageName = processingEnv.getOptions().get(DEFAULT_PACKAGE);
if (packageName == null)
packageName = "nuclei.data";
Context context = new Context(allModels.values(), packageName, null);
context.render(cfg, modelType, processingEnv.getFiler());
}
}
}
}