On my HTML page, I have a boolean checkbox that looks like this:
<input type="checkbox" id="pnrCheckbox" name="includesPnr" value="true"/>
<!-- This field is generated by Spring as a workaround for something -->
<input type="hidden" name="_includesPnr" value="on"/>
When I use Ajax to send a JSON string to my controller, the network traffic in my browser displays this form data:
_includesPnr: on
Upon deserializing the JSON back to my Java model in the controller using Jackson, I encounter an issue mapping the _includesPnr property due to the underscore. Even manually mapping the property like this:
@JsonProperty(value="_includesPnr")
private Boolean includesPnr;
fails because 'on' is not a valid boolean value.
How can I ensure that the property is sent with the correct name and values of true/false instead of on/off?