@Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix("/WEB-INF/views/");
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   return templateResolver;
 }
 @Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
   templateResolver.setPrefix("views/");
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   return templateResolver;
 }
 @Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix(VIEWS);
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   templateResolver.setCacheable(false);
   return templateResolver;
 }
 @Override
 public String generatePageHtml(ITestPage test) {
   TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
   templateResolver.setTemplateMode("HTML5");
   templateResolver.setCharacterEncoding("UTF-8");
   TemplateEngine templateEngine = new TemplateEngine();
   templateEngine.setTemplateResolver(templateResolver);
   Locale locale = LocaleUtils.toLocale("fr");
   final Context ctx = new Context(locale);
   ctx.setVariable("test", test);
   String htmlOutput = templateEngine.process("new_test_report_template.html", ctx);
   return htmlOutput;
 }
 @Bean
 public TemplateResolver taskTemplateResolver() {
   final TemplateResolver resolver = new TemplateResolver();
   resolver.setPrefix(this.storageService.getStoragePath());
   resolver.setSuffix(".html");
   resolver.setTemplateMode("HTML5");
   resolver.setOrder(3);
   resolver.setCacheable(false);
   resolver.setCharacterEncoding("UTF-8");
   resolver.setResourceResolver(new OlympusCustomThymeleafResourceResolver());
   return resolver;
 }
 @Bean
 public TemplateResolver customTemplateResolver() {
   if (StringUtils.isEmpty(this.customPagesPath)) {
     return null;
   }
   final TemplateResolver resolver = new TemplateResolver();
   resolver.setPrefix(this.customPagesPath);
   resolver.setSuffix(".html");
   resolver.setTemplateMode("HTML5");
   resolver.setOrder(4);
   resolver.setCacheable(false);
   resolver.setCharacterEncoding("UTF-8");
   resolver.setResourceResolver(new FileResourceResolver());
   return resolver;
 }
 @Test
 public void overrideCharacterEncoding() throws Exception {
   EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.encoding:UTF-16");
   this.context.register(
       ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
   this.context.refresh();
   this.context.getBean(TemplateEngine.class).initialize();
   ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
   assertThat(resolver instanceof TemplateResolver).isTrue();
   assertThat(((TemplateResolver) resolver).getCharacterEncoding()).isEqualTo("UTF-16");
   ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
   assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
   assertThat(views.getContentType()).isEqualTo("text/html;charset=UTF-16");
 }
Beispiel #8
0
  public void setResponse(Pair<ABSString, ABS.StdLib.List<ABSValue>> pair) throws Exception {
    TemplateResolver templateResolver = new TemplateResolver();
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setSuffix(".html");
    templateResolver.setResourceResolver(new ResourceResolver());

    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);

    List_Cons<ABSValue> data;

    if (pair != null) {
      String view = DataTransformer.convertABSStringToJavaString((ABSString) pair.getArg(0));
      Context ctx = new Context();
      if (!(pair.getArg(1) instanceof List_Nil)) {
        data = (List_Cons<ABSValue>) pair.getArg(1);
        ArrayList<Object> dataModels = DataTransformer.convertABSListToJavaList(data);

        if (dataModels.size() > 1) {
          ctx.setVariable("dataList", dataModels);
        } else {
          ctx.setVariable("data", dataModels.get(0));
        }
      }
      ctx.setVariable("requestMethod", this.request.getMethod());
      ctx.setVariable("requestURI", this.request.getRequestURI());
      ctx.setVariable("requestContextPath", this.request.getContextPath());
      ctx.setVariable(
          "requestRoute", this.getRoute(request.getRequestURI(), request.getContextPath()));

      this.response = templateEngine.process(view, ctx);
    } else {
      this.response = "<h3>ERROR 404: PAGE NOT FOUND</h3>";
      this.response += "<span style='font-size:0.8em;'>ABS Server: " + new Date() + "</span><br />";
    }
  }
 /*
  * Configure Template Resolver - Thymeleaf
  */
 @Bean
 public TemplateResolver webTemplateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix(TEMPLATE_RESOLVER_PREFIX);
   templateResolver.setSuffix(TEMPLATE_RESOLVER_SUFFIX);
   templateResolver.setTemplateMode(TEMPLATE_RESOLVER_TEMPLATE_MODE);
   templateResolver.setCharacterEncoding(TEMPLATE_RESOLVER_CHAR_ENCODING);
   templateResolver.setCacheable(false);
   return templateResolver;
 }