【发布时间】:2021-05-28 00:02:24
【问题描述】:
我正在使用 Spring Boot 和 Thymeleaf。如果用户单击按钮,则该按钮应向用户显示另一个页面。我唯一的问题是,url 需要一个参数。
我试过了,但这不起作用:
<form th:action="@{/removeserver(id=${serverId})}">
<input type="submit" value="Remove server"/>
</form>
它适用于以下链接,但不能用作按钮:
<a th:text="Remove" th:href="@{/removeserver(id=${serverId})}"></a>
那么如何将带有参数的 url 显示为按钮呢?
【问题讨论】:
-
当你点击链接时浏览器执行
GET请求,而form提交数据时默认使用POST方法。添加到您的表单method="GET"并且您的代码应该可以工作。
标签: java html spring-boot spring-mvc thymeleaf