0

I'm using thymeleaf and spring boot and I want send request parameters to controller method but thymeleaf is also sending empty values, how can I send only parameters that actually have value.

     <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>

And the thing is when I submit form without writing anything into input i got url:

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

and I want normal url if no values are present:

http://localhost:8090/browse
  • 1
    Possible duplicate of [How to prevent submitting the HTML form's input field value if it empty](https://stackoverflow.com/questions/8029532/how-to-prevent-submitting-the-html-forms-input-field-value-if-it-empty) – Metroids Dec 11 '18 at 17:43
  • 1
    This is how browsers submit empty parameters, Thymeleaf has nothing to do with this -- the only way to accomplish this is with javascript (like the duplicate question I added). – Metroids Dec 12 '18 at 22:22

0 Answers0