spring-boot - Thymeleaf 模板未显示用户名
问题描述
我的主页没有显示用户名,我正在使用 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>
解决方案
尝试这个:
<p>
Welcome <span th:text="${#request.userPrincipal.name}">User</span>
</p>
推荐阅读
- javascript - Google Workspace 插件错误:TypeError:无法读取未定义的属性“stringInputs”
- .net - 需要更改 IE 中的设置以查看在 .net 中开发的 Web 应用程序的下拉列表
- flutter - Flutter 通过 API 上传数据
- laravel - 将请求重定向到 http 和 https
- python - 从 Python 中的多个变量中获取单个返回变量的输出
- python - 如何通过python(DAG)通过字典输入创建路径
- c# - 如何将引导模板集成到Angular中,请以正确的方式举例
- python - 如何获取列表元素的组合?
- database - 就处理遗留数据项或列的新数据库设计而言,最好的方法是什么?
- heroku - Heroku 应用程序错误,错误代码为 H10