1、在页面上添加一个命名空间
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
2、在页面按钮上添加权限属性
<button type="button" class="btn btn-danger btn-sm" id="topBtn" th:disabled="${post.type==1} " sec:authorize="hasAnyAuthority('moderator')">置顶</button> <button type="button" class="btn btn-danger btn-sm" id="wonderfulBtn" th:disabled="${post.status==1}" sec:authorize="hasAnyAuthority('moderator')">加精</button> <button type="button" class="btn btn-danger btn-sm" id="deleteBtn" th:disabled="${post.status==2}" sec:authorize="hasAnyAuthority('admin')">删除</button>