1、判空指针很重要!
2、单元测试很必要,在和前台vue接时才发现一些小错误还存在,比如sql语句的参数没有用逗号分隔,方法中少赋值一个参数等等。
3、Thymeleaf应用汇总:
1)map遍历:
<li th:each="menu:${menuMap}">
<a th:href="${menu.key.url}" th:text="${menu.key.name}"></a>
<ul>
<li th:each="child, childStat:${menu.value}">
<a th:href="${child.url}" th:text="${child.name}"></a>
</li>
</ul>
</li>
2)list遍历:
<li th:each="page,pageStat:${pageInfo.list}">
<a th:title="${page.name}" th:href="${page.url}+'?id='+${page.id}+'&cur='+${cur}" target="_blank">
<div class="news-title" th:utext="${page.name}"></div>
<p th:text="${page.summary}"></p>
<span th:text="${page.newsdate}"></span>
</a>
</li>
3)链接加参数,所有的链接都应该使用@{}方式,包括img的src和a的href
<p>当前 <span th:text="${pageInfo.pageNum}"></span> 页,
总 <span th:text="${pageInfo.pages}"></span> 页,
共 <span th:text="${pageInfo.total}"></span> 条记录</p>
<a th:href="@{${which}(cur=${cur})}">首页</a>
<a th:href="@{${which}(cur=${cur},pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}">上一页</a>
<a th:href="@{${which}(cur=${cur},pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}">下一页</a>
<a th:href="@{${which}(cur=${cur},pageNum=${pageInfo.pages})}">尾页</a>
4)通过style加样式
th:style="'background-color:'+ ${commonSystem.bgColor}+''"
5)引入文件
<div th:replace="footer :: common"></div>
在footer.html中
<div th:fragment="common" class="foot">
<!-- 内容 -->
</div>
4、文字滚动插件
liMarquee,当滚动内容所在div宽度过宽时,不能实现无缝滚动,需缩小宽度。