【问题标题】:Thymeleaf template not showing usernameThymeleaf 模板未显示用户名
【发布时间】:2020-07-05 05:46:27
【问题描述】:

我的主页没有显示用户名,我正在使用 sec:authentication 标签

<li sec:authorize="isAuthenticated()"><a th:href="@{/logout}">Logout</a></li>
   </ul>
   </div>
   </nav>
   <br><br>
   <p>
			Welcome <span sec:authentication="principal.username">User</span>
   </p>

【问题讨论】:

标签: spring-boot thymeleaf


【解决方案1】:

试试这个:

<p>
  Welcome <span th:text="${#request.userPrincipal.name}">User</span>
</p>

【讨论】:

  • 你能建议如何获取用户的其他详细信息
猜你喜欢
  • 2021-07-05
  • 2019-11-11
  • 2019-05-04
  • 2021-12-01
  • 2022-12-19
  • 1970-01-01
  • 2014-02-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多