zoukankan      html  css  js  c++  java
  • VelocityEngineUtils.mergeTemplateIntoString(.. spring移除了类,没有这个方法的解决办法

    之前的版本创建邮件发送的方式:

    String text = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, "模板名称.vm", "UTF-8", model);

    由于VelocityEngineUtils类移除,用这个方式创建:

            VelocityEngine velocityEngine = new VelocityEngine();
            Properties p = new Properties();
            p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "src/main/resources/templates");
            velocityEngine.init(p);
    
            Map<String, Object> model = new HashMap<>();
            model.put("模板参数", "值");
            VelocityContext velocityContext = new VelocityContext(model);
            StringWriter writer = new StringWriter();
            velocityEngine.mergeTemplate("template.vm", "UTF-8", velocityContext, writer);
            String text = writer.toString();
  • 相关阅读:
    Palindrome
    Girls' research
    最长回文
    Water Tree
    Alternating Current
    Psychos in a Line
    Feel Good
    Color the Fence
    javaScript内置类Date,Math等
    DOM之兄弟节点
  • 原文地址:https://www.cnblogs.com/cmmplb/p/15174984.html
Copyright © 2011-2022 走看看