<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<title>图片展示</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>图片展示</h1>
<br>
<hr>
<br>
<div th:each="i,iStat:${urls}">
<img src="" th:attr="src=${i}"><br />
<h5>
网络地址 :
<button
th:onclick="'javascript:copytt(\'texta'+${iStat.index}+'\',\''+${i}+'\',\'buti'+${iStat.index}+'\')'" th:attr="id=buti+${iStat.index}" style="background-color: #fff;">点击复制</button>
</h5>
<span th:text="${i}"></span>
<textarea id="text" style="opacity:0.0;cursor: default;width:1px;height:1px;" readonly="readonly"
th:attr="id=texta+${iStat.index}"></textarea>
<br>
<hr>
<br>
</div>
<br>
</body>
<script type="text/javascript" src="/ejs/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
function copytt(id,url,bid) {
jqid = '#'+bid;
$(jqid).css('color','#87B918');
$(jqid).html('复制成功');
var ele = document.getElementById(id);
ele.innerHTML = url;
ele.select();
document.execCommand("Copy");
}
</script>
</html>
onclick事件参考 thymeleaf下设置onclick属性