<html> <head> <title></title> <script src="jquery-1.11.2.js"></script> <script> $(function() { $('#chek').click(function () { if ($(this).attr('checked')) { $("#btnSubmit").html("true"); } else { $("#btnSubmit").html("false"); } }); }); </script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <div> <form method="post"> <input type="checkbox" id = "chek" name="readAlread" value="true"> true <input type="checkbox" name="readAlread" value="false"> false <br> <br> <input id ="btnSubmit" type="submit" value="submit" onclick="chek">Добавить </form> </div> </body> </html> Sorry, I'm new, I looked everywhere on the Internet, but I could not find the answer to my question .. If a check mark is not selected on the cheackbox, then I need to send the server false. On my server, my variable type is stored boolean. I work in IDEA, I use java, spring, hibernate. I have a query in the controller class
@PostMapping("/add") public String add(@RequestParam Boolean readAlready, Map<String, Object> model) { ...... return "main"; } If I don’t select the checkboxe checkbox, then I get an error on the site
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sat May 26 20:09:56 MSK 2018 There was an unexpected error (type=Bad Request, status=400). Required Boolean parameter 'readAlready' is not present