栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Springboot中temlates和static

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Springboot中temlates和static

文章目录
    • static
    • templates

springboot默认 static中放静态页面,而templates中放动态页面

**注:html链式引入css或js时,路径默认是从static开始的 **

lg : href="/css/mycss.css"

加入thymleaf依赖后,springboot中controller中的跳转页面操作,自动跳转templates下的页面,而不会扫描static下的页面

static

static文件夹默认存放的是静态资源 静态页面

static文件夹中的html页面为静态页面,可以直接在浏览器地址访问xxx.html,如果用controller跳转到该页面的话

@RequestMapping("/totest")
    public String totest(){
    	//返回值的路径要加入.html后缀
        return "/test.html";
    }
templates

templates文件夹存放的时动态页面(使用了thymleaf模板引擎)

动态页面不能通过浏览器地址直接访问,所以要使用请求进行跳转

@RequestMapping("/tofind")
public String tofind(){
    //返回值的路径不需要加入.html后缀
    return "/find";
}

注:加入thymleaf依赖后,springboot中controller中的跳转页面操作,只跳转templates下的动态页面,而不能跳转static下的动态页面(个人理解)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/328047.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号