リンク://spring-boot/spring-boot-hello-world-example-mustache/[Spring Boot Mustache]テンプレート環境で、Mustacheのページの `{{変数}} ‘に値を割り当てなかった場合、https://github.com/samskivert/jmustache[jmustache]は次のエラーメッセージをスローします:

com.samskivert.mustache.MustacheException$Context: No method or field with name 'variable' on line xx
    at com.samskivert.mustache.Template.checkForMissing(Template.java:316) ~[jmustache-1.13.jar:na]    at com.samskivert.mustache.Template.getValue(Template.java:224) ~[jmustache-1.13.jar:na]    at com.samskivert.mustache.Template.getValueOrDefault(Template.java:269) ~[jmustache-1.13.jar:na]....

____P.S Tested with Spring Boot 1.5.2.REL____EASE

=== Solution 1

If the variable is optional, try to wrap like this:

{{#変数}}
      {{。}}
  {{/変数}}

===解決策2

代わりに、Springブートで、 `Mustache.Compiler`を
グローバルにデフォルト値を指定する:

SpringBootWebApplication.java

パッケージcom.hostingcompass.web;

import com.samskivert.mustache.Mustache;インポートorg.springframework.boot.SpringApplication;インポートorg.springframework.boot.autoconfigure.SpringBootApplication;インポートorg.springframework.boot.autoconfigure.mustache.MustacheEnvironmentCollector; import org.springframework.context.annotation.Bean;インポートorg.springframework.context.annotation.ComponentScan;インポートorg.springframework.core.env.Environment;

@SpringBootApplication @ComponentScan({“com.mkyong”})public class SpringBootWebApplication {

public static void main(String[]args){SpringApplication.run(SpringBootWebApplication.class、args); }

MustacheEnvironmentCollectorコレクタ=新しいMustacheEnvironmentCollector(); collector.setEnvironment(environment);

}

}

===参考文献

。リンク://spring-boot/spring-boot-hello-world-example-mustache/[Spring
ブートHello Worldの例 - 口ひげ]。 https://github.com/samskivert/jmustache#default-values[jmustache  -
デフォルト値]
link://tag/default/[default]link://tag/jmustache/[jmustache]link://tag/mustache/[mustache]リンク://tag/spring-boot/[spring boot]