问题描述
我的表单基于Thymeleaf,我不使用表,因为它具有许多字段。
在表单中,我有3个按钮,一个是提交,另一个是链接。我想使用链接按钮使用向字符串发送字符串到控制器的参数进行查询。
我想获取URL中传递给控制器的字符串,并使用@RequestParam批注接收数据。
我没有任何错误消息,发生的是字符串到达控制器为空。
这是我的链接按钮:
<a class="btn btn-success text-white btn-sm mr-3 " style="border-radius: 16px;" th:href="@{/config/item/items/select(productId=${item.productId})}">
Search
</a>
这是我在其中输入用户查询的文本字段:
<div class="col-2 form-group"
th:classappend="${#fields.hasErrors('item.productId')}? 'has-error':''">
<label for="productId"><strong>Item id </strong></label> <input
type="text" class="form-control" id="productId" name="productId"
th:field="${item.productId}">
</div>
所有这些都在我的表单中:
<form th:action="@{/config/item/items/save}" method="get"
th:model="${item}">
我使用了这两个,但没有结果:
th:href="@{'/config/item/items/select'+${item.productId}}"
th:href="@{|/config/item/items/select${item.productId}|}"
我在第九章的https://www.thymeleaf.org/doc/articles/standardurlsyntax.html中查看了Thymeleaf提供的文档。 而且我也看过教程,但这没用。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)