我是百里香新手。最近我无意中遇到了以下情况。这是我的 Thymeleaf html 页面的一部分:
<!-- an delete button link -->
<a th:href="@{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ?') )) return false" >
Delete
</a>
Run Code Online (Sandbox Code Playgroud)
这段代码按预期工作得很好。不过,我想添加员工姓名作为确认的一部分。这是代码:
<!-- an delete button link -->
<a th:href="@{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ' + '\'+${tempEmployee.firstName}+\'' +'?' ) )) return false" >
Delete
</a>
Run Code Online (Sandbox Code Playgroud)
不幸的是结果是:
Are you sure you want to delete this employee
'+${tempEmployee.firstName}+'。
Thymeleaf …