Templates mit jdk.httpserver nutzen
ulrich
2021-07-06 a6f1f3292dce4eb1aa7a162e06bf0980b90cb5f8
Logging erweitert
1 files modified
3 ■■■■■ changed files
src/de/uhilger/httpserver/template/TemplateActor.java 3 ●●●●● patch | view | raw | blame | history
src/de/uhilger/httpserver/template/TemplateActor.java
@@ -70,12 +70,15 @@
    Map attributes = exchange.getHttpContext().getAttributes();
    String fileBase = helper.getAttrStr(attributes, FileHandler.ATTR_FILE_BASE, STR_EMPTY);
    File fileRoot = new File(fileBase);    
    logger.fine("fileRoot: " + fileRoot.getAbsolutePath());
    String template = helper.getAttrStr(attributes, ATTR_TEMPLATE, STR_EMPTY);
    File templateFile = new File(fileRoot, template);
    if(templateFile.exists()) {
      logger.fine("using template " + templateFile.getAbsolutePath());
      mf = new NeonMustacheFactory(fileRoot);
      m = mf.compile(template);
    } else {
      logger.fine("template " + templateFile.getAbsolutePath() + " not found");
      mf = new NeonMustacheFactory();
      m = mf.compile(template);
    }