我在Spring Boot Application中具有以下项目结构-/
templates/
home /
index.html
/templates/includes/header.html
我想在索引文件中包含头文件。我已经尝试了链接-https: //stackoverflow.com/questions/23538693/include-html-page-in-thymeleaf# =
但是冒号“ ::”显示错误。
我是百里香的新手。有人可以解释吗?谢谢。
我在玩 Java 的 Optional 并认为它就像一个 if else 块。但是在下面的代码中,即使name变量不是执行块null的内容orElse。有什么解释吗?
import java.util.Optional;
class Scratch {
public static void main(String[] args) {
String name = "some text";
System.out.println(
Optional.ofNullable(name)
.map(n -> mapped())
.orElse(getOrElse()));
}
static String mapped(){
System.out.println("mapped -- block executed");
return "mapped";
}
static String getOrElse(){
System.out.println("orElse -- block executed");
return "orElse";
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
mapped -- block executed
orElse -- block executed
mapped
Run Code Online (Sandbox Code Playgroud)