SpringBoot静态资源访问

1,静态资源:访问js,css,图片    动静分离(CDN缓存)

传统Web工程   属于webapps里面

 

springboot里面有要求:静态资源存放在resources目录下的static文件夹下

 

2.整合Freemarker视图层

.jsp###.html   .htm

微静态html

 

1.pom文件引入      

<!-- 引入freeMarker的依赖包 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>

 

2.在src/resources/  新建一个文件夹templates  并在下面新建一个*.ftl文件

@Controller
public class FtlIndexController {

@RequestMapping("ftlIndex")
public String ftlIndex(Map<String ,Object> map) {
map.put("name", "谭磊");
map.put("age", "20");
map.put("sex", "0");
return "ftlIndex";
}
}

 

这是我的第一个ftl
${name} ### ${age} ###${sex}

<#if sex="0">
男生
<#else>
女生
</#if>

 

posted @ 2019-01-10 23:55  言西早石头侠  阅读(518)  评论(0编辑  收藏  举报