From d6268be92691eb6c02db2951623460388fea65b6 Mon Sep 17 00:00:00 2001 From: toyg Date: Sun, 10 Feb 2019 17:34:38 +0000 Subject: [PATCH] Update to Velocity 2.0, where context keys are always String. --- spark-template-velocity/pom.xml | 4 ++-- .../java/spark/template/velocity/VelocityTemplateEngine.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spark-template-velocity/pom.xml b/spark-template-velocity/pom.xml index 3f3c701..b0ac482 100644 --- a/spark-template-velocity/pom.xml +++ b/spark-template-velocity/pom.xml @@ -40,8 +40,8 @@ org.apache.velocity - velocity - 1.7 + velocity-engine-core + 2.0 com.sparkjava diff --git a/spark-template-velocity/src/main/java/spark/template/velocity/VelocityTemplateEngine.java b/spark-template-velocity/src/main/java/spark/template/velocity/VelocityTemplateEngine.java index 8005c28..1aead3a 100644 --- a/spark-template-velocity/src/main/java/spark/template/velocity/VelocityTemplateEngine.java +++ b/spark-template-velocity/src/main/java/spark/template/velocity/VelocityTemplateEngine.java @@ -75,12 +75,13 @@ public VelocityTemplateEngine(VelocityEngine velocityEngine) { * {@inheritDoc} */ @Override + @SuppressWarnings("unchecked") public String render(ModelAndView modelAndView) { String templateEncoding = Optional.ofNullable(this.encoding).orElse(StandardCharsets.UTF_8.name()); Template template = velocityEngine.getTemplate(modelAndView.getViewName(), templateEncoding); Object model = modelAndView.getModel(); if (model instanceof Map) { - Map modelMap = (Map) model; + Map modelMap = (Map) model; VelocityContext context = new VelocityContext(modelMap); StringWriter writer = new StringWriter(); template.merge(context, writer);