thymeleaf 常遇问题

1:纯数字渲染列表

     用到的方法i: ${#numbers.sequence(1,type.number)} // 此处设置取值范围

       <option th:each="i:${#numbers.sequence(1,type.number)}" th:text="${i}"</option>


<div class="huxin" style="display:flex;flex-flow: row;justify-content: flex-start;">
	<div th:each="type:${types}">
		<select name="">
			<option value="">0</option>
			<option th:each="i:${#numbers.sequence(1,type.number)}" th:text="${i}"</option>
		</select>
		<span style="font-size: 12px;" th:text="${type.name}"></span>
	</div>
</div>

效果图

 

2:方法带参数(亲测无误)

 需注意参数需要用[[]]

th:onchange="javascript:huxin([[${type.name}]])"
<div class="huxin" style="display:flex;flex-flow: row;justify-content: flex-start;">
	<div th:each="type:${types}">
		<select name="" th:onchange="javascript:huxin([[${type.name}]])">
			<option value="">0</option>
			<option th:each="i:${#numbers.sequence(1,type.number)}" th:text="${i}"</option>
	    </select>
		<span style="font-size: 12px;" th:text="${type.name}"></span>
	</div>
</div>

3:常用标签

 此处引用:https://blog.csdn.net/malimingwq/article/details/79329921

4:公共head/html/.. 封装

封装:

<footer th:fragment="footer" id="footer-main" class="footer-main container-fluid no-padding">
    <!-- Top Footer -->
   // 公共部分HTML
</footer><!-- Footer Main /- -->

引用:

在页面直接引用

<!-- Footer Main -->
<footer th:replace="footer::footer"></footer>

5:导入外部HTML报错

    需要引入thymeleaf标签

<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<!--引入thymeleaf标签-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="en"><!--<![endif]-->

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值