Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Validation with BindingResult attribute never hit the targeted controller method
    primarykey
    data
    text
    <p>I have a form that I submitted to upload file:</p> <pre><code>&lt;form id="uploadForm" action="#" method="POST" enctype="multipart/form-data"&gt; &lt;div class="instruction popup_inst"&gt; &lt;span class="popup_logo"&gt;[@spring.message "pandaLogo"/]&lt;/span&gt; &lt;div class="float_right"&gt; &lt;input type="button" id="cancelBtn" class="btn" onclick="closePopupFunctionality();" value="[@spring.message "cancelButton"/]" /&gt; &lt;input class="btn" type="submit" id="submit" onclick="validateFileInput();" value="[@spring.message "uploadButton"/]" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;span class="popup_title"&gt;[@spring.message "uploadFile"/]&lt;/span&gt; &lt;div class="popup_container"&gt; [@spring.bind "assayAssessmentsRequestBean"/] [@spring.formInput path="assayAssessmentsRequestBean.designabilityFile.file" fieldType="file" attributes="title='path' class='upload' accept='.txt,.csv,.zip'" /] [@spring.formHiddenInput path="assayAssessmentsRequestBean.dateOfAssessment" attributes="" /] [@spring.formHiddenInput path="assayAssessmentsRequestBean.id" attributes="" /] [@spring.showErrors " " "error" /] &lt;/div&gt; &lt;input id="uploadfile" type="hidden" value="${uploadfile}"/&gt; &lt;/form&gt; </code></pre> <p>this form hits the following method in controller:</p> <pre><code>@RequestMapping(value = "/uploadFile",method= RequestMethod.POST) public ModelAndView uploadFile(@ModelAttribute(value = "assayAssessmentsRequestBean")AssayAssessmentsRequestBean assayAssessmentsRequestBean,HttpSession session,BindingResult result) throws PanDaApplicationException { //mycode } </code></pre> <p>what happen is that the method never called and when I remove the BindingResult attribute the method is invoked.</p> <p>I tried another approach which is having BeanPropertyBindingResult attribute and pass target object to be validated and it works but never return errors.</p> <pre><code>@RequestMapping(value = "/uploadFile",method= RequestMethod.POST) public ModelAndView uploadFile(@ModelAttribute(value = "assayAssessmentsRequestBean")AssayAssessmentsRequestBean assayAssessmentsRequestBean,HttpSession session/*,BindingResult result*/) throws PanDaApplicationException { logger.info(assayAssessmentsRequestBean.getDesignabilityFile().getFile()); BindingResult result=new BeanPropertyBindingResult(assayAssessmentsRequestBean.getDesignabilityFile(),"designabilityFile"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload