Thymeleaf 链接引用例子

目录结构:

1、第一种使用@{}来引用

使用/是相对于应用程序上下文

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/css/aa.css}"/>
</head>
<body>
<p class="aa">测试链接引用</p>
</body>
</html>

2、第二种使用相对路径也就是(../)  在这种情况下,应用程序上下文将不会作为URL的前缀

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{../css/cc.css}"/>
</head>
<body>
<p class="cc">测试链接引用</p>
</body>
</html>

3、第三种使用@{~}

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{~/../css/aa.css}"/>
</head>
<body>
<p class="aa">测试链接引用2</p>
</body>
</html>

个人感觉他跟第一种差不多。。“~”只能出现一次,在链接上,不能写成“~/~/cc.css” 这样,会报404

4、使用//  浏览器将使用在显示的页面中使用的相同的HTTP或HTTPS协议

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{//localhost:8080/css/cc.css}"/>
</head>
<body>
<p class="cc">测试链接引用</p>
</body>
</html>

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
百度map,百度map API,百度地图 实现百度地图动态搜索、静态地图动态插入 [email protected] js 内容如下: /** 加载地图的主控类 */ var MapControl={ staticWith : 512,//链静态图宽度 staticHeight : 320,//链静态图的高度 container : 'mapcontainer',//显示map的节点id defzoom:12,//默认缩放比例 map : '', marker : '', city : '深圳', infoWinContent : '请移动此标记到您的婚礼地点位置!', /** 提示信息窗内容 */ infoOpts : { width : 100, // 信息窗口宽度 height: 50, // 信息窗口高度 title : "提示:" // 信息窗口标题 }, /** *默认显示窗口 */ defWindow : function(){ this.map = new BMap.Map(this.container); this.map.centerAndZoom(this.city,this.defzoom); // 通过城市名初始化地图 this.map.addEventListener("load", function(){ // 初始化方法执行完成后即可获取地图中心点信息 MapControl.marker = new BMap.Marker( this.getCenter()); // 创建标注 this.addOverlay(MapControl.marker ); // 将标注添加到地图中 MapControl.marker.enableDragging(); var infoWindow = new BMap.InfoWindow(MapControl.infoWinContent, MapControl.infoOpts); // 创建信息窗口对象 MapControl.marker.addEventListener("mouseover", function(){ this.openInfoWindow(infoWindow); // 打开信息窗口 }) MapControl.marker.addEventListener("mouseout", function(){ this.closeInfoWindow(); // 打开信息窗口 }) }) //map 增加操作 this.map.addControl(new BMap.NavigationControl()); this.map.addControl(new BMap.ScaleControl()); this.map.addControl(new BMap.OverviewMapControl()); this.map.addControl(new BMap.MapTypeControl()); }, /** * 搜索地址 */ search : function(address){ if(this.map=='' || this.map == 'undefined' || address=='' ){ return ; } this.city=address; this.defWindow(); }, /** * 获取静态图片地址 */ getStaticMap : function(){ if(this.map=='' || this.map == 'undefined' || this.marker=='' ){ return ; } var center=this.map.getCenter().lng+','+this.map.getCenter().lat; var markers= this.marker.getPosition().lng+','+this.marker.get

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值