I am using checkbox in my application to pass one value in spring .When i checked it it is working fine but the problem lying when I unchecked it.It shows error -
WARN : org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Handler execution resulted in exception: Required String parameter 'isFl' is not present
here isFl is the name of checkbox which I need to pass.I search lot and got many answer applied in my program but haven't got desired result.
If anyone knowing the answer please help thanks in advance.
controller program
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public ModelAndView uploadPost(@RequestParam String fileName, @Validated Template template,
@Validated TemplateBean templateBean,
@RequestParam MultipartFile file,
HttpServletRequest request,**@RequestParam String isFl**) throws Exception
{
ModelAndView model = new ModelAndView("upload");
if(isFl!=null){
addTemplate.setFl(Integer.parseInt(isFl));
}
else{
addTemplate.setFl(0);//false value
}
jsp file
<input id="checkbox" type="checkbox" **name="isFl"** value="1" >Facility letter
there is lot more things but i have only uploaded relevent to my question
checkboxtag and make it part of your template bean.