java 如何在thymeleaf中使用“sec:authentication=“name”“构建表单操作URL

thtygnil  于 2023-03-16  发布在  Java
关注(0)|答案(1)|浏览(138)

示例:〈form th:action="@{/您好/${#身份验证.用户名}}”
试着通过authentication.username作为参数到控制器

n8ghc7c1

n8ghc7c11#

你可以用
<form th:action="@{/hello/{id}/(id=${#authentication.getName()})}">
Thymeleafs documentation on standard url语法非常详细地解释了如何将参数添加为路径变量或请求参数。
添加此答案仅用于学习目的。您不需要像这样发送用户名。从身份验证主体在服务器端访问它。

相关问题