标签:control 模板 jar包 ppi 目录 meta oca and addm
webjars
:以JAR包的方式引入静态资源;/webjars/**
,都去classpath:/META-INF/resources/webjars/
目录下加载资源;/**
访问当前项目的任何资源(即静态资源文件夹)
classpath:/META-INF/resources/
classpath:/resources/
,classpath:/static/
,classpath:/public/
,/
:当前项目的根路径// WebMvcAutoConfiguration.java
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!this.resourceProperties.isAddMappings()) {
logger.debug("Default resource handling disabled");
return;
}
Integer cachePeriod = this.resourceProperties.getCachePeriod();
if (!registry.hasMappingForPattern("/webjars/**")) {
customizeResourceHandlerRegistration(registry
.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/")
.setCachePeriod(cachePeriod));
}
String staticPathPattern = this.mvcProperties.getStaticPathPattern();
if (!registry.hasMappingForPattern(staticPathPattern)) {
customizeResourceHandlerRegistration(
registry.addResourceHandler(staticPathPattern)
.addResourceLocations(
this.resourceProperties.getStaticLocations())
.setCachePeriod(cachePeriod));
}
}
// pom.xml
<properties>
<!-- 切换 thymeleaf 版本 --
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
// classpath:/templates/, 存放HTML页面
success.html
// 编写Controller
@RequestMapping("/success")
public String success(){
return "success";
}
参考资料:
标签:control 模板 jar包 ppi 目录 meta oca and addm
原文地址:https://www.cnblogs.com/linkworld/p/9142306.html