-1

I want to send a string from an HTML form to a Spring Boot controller but I would like this string not to be visible to the client. I would like to use the hidden field but something is not working and I don't understand where I'm wrong. In the code you will find all my proofs.

    <form th:action="@{/test-server-asincrono}" th:object="${InterrompiAsincrono}" method="POST">
    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">
    <!--/*<input type="hidden" th:field="*{interrompi}" id="interrompi" th:value="si">*/-->
    <!--/*<input type="hidden" th:field="*{interrompi}" id="interrompi" value="${'si'}">*/-->
    <!--/*<input type="hidden" th:field="*{interrompi}" id="interrompi" value="si">*/-->
    <!--/*<input type="hidden" th:name="*{interrompi}" id="interrompi" value="si">*/-->
    <select th:field="*{interrompi}" class="form-select">
        <option th:value="si">Si</option>
    </select>
    <input type="submit" value="Interrompi il test" class="btn btn-primary">
    </form>
Federico Galimberti
  • 185
  • 1
  • 3
  • 11
  • Is it te CSRF related hidden field that is not working? Or one of the commented out ones? – Wim Deblauwe Apr 25 '22 at 11:40
  • The CSRF input tag works perfectly, all commented tags don't work. I would like to remove the select tag and send the string "si" to the @Service with a select tag. It doesn't make much sense to have a single-choice select tag. Is the question clearer to you? – Federico Galimberti Apr 25 '22 at 12:45

1 Answers1

0
<input type="hidden" name="interrompi" value="si">
Federico Galimberti
  • 185
  • 1
  • 3
  • 11