首页 > 解决方案 > Thymeleaf 请求参数

问题描述

我正在使用 thymeleaf 和 spring boot,我想将请求参数发送到控制器方法,但 thymeleaf 也在发送空值,我怎样才能只发送实际具有值的参数。

     <form class="col s12" th:action="@{/browse}" method="get">
           <input id="newStatusName" th:name="status">
           <input id="driverName" th:name="driver">
           <input id="vehicleName" th:name="vehicle">
           <button> Search </button>
     </form>

问题是当我提交表单而没有在输入中写入任何内容时,我得到了 url:

http://localhost:8090/browse&status=&driver=&vehicle=

如果没有值,我想要正常的 url:

http://localhost:8090/browse

标签: parametersrequestthymeleaf

解决方案


推荐阅读