A hidden field is an HTML form control whose value is submitted with the form without being displayed. In a Spring Security application, it carries a CSRF token required by protected state-changing requests. section 9.2
Use a hidden field when:
- A custom POST, PUT, or DELETE form must include the CSRF token. section 9.2
- A form submits a value that should not appear as an editable or visible control. section 9.2
Spring Security and Thymeleaf
Add an input with type="hidden", bind its name to ${_csrf.parameterName}, and bind its value to ${_csrf.token}. Without it, the POST to /product/add receives HTTP 403 Forbidden; with it, the controller executes.
