Note that there are some explanatory texts on larger screens.

plurals
  1. POAn Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments
    primarykey
    data
    text
    <p>I am teaching myself Spring by dissecting example applications and then adding code here and there to test theories that I develop during the dissection. I am getting the following error message when testing some code that I added to a Spring application: </p> <pre><code>An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply </code></pre> <p>The method to which the error message refers is: </p> <pre><code>@RequestMapping(value = "/catowners", method = RequestMethod.GET) public String findOwnersOfPetType(Integer typeID, BindingResult result, Map&lt;String, Object&gt; model) { // find owners of a specific type of pet typeID = 1;//this is just a placeholder Collection&lt;Owner&gt; results = this.clinicService.findOwnerByPetType(typeID); model.put("selections", results); return "owners/catowners"; } </code></pre> <p>This error message was triggered when I tried to load the /catowners url pattern in the web browser. I have reviewed <a href="http://static.springsource.org/autorepo/docs/spring/3.2.0.M1/api/org/springframework/web/bind/annotation/RequestMapping.html" rel="noreferrer">this page</a> and <a href="https://stackoverflow.com/questions/10449532/spring-mvc-3-1-exception-an-errors-bindingresult-argument-is-expected-to-be-im">this posting</a>, but the explanation does not seem clear. </p> <p>Can anyone show me how to fix this error, and also explain what it means?</p> <p>EDIT:<br> Based on Biju Kunjummen's response, I changed the syntax to the following: </p> <pre><code>@RequestMapping(value = "/catowners", method = RequestMethod.GET) public String findOwnersOfPetType(@Valid Integer typeID, BindingResult result, Map&lt;String, Object&gt; model) </code></pre> <p>I am still getting the same error message. Is ther something I am not understanding? </p> <p>SECOND EDIT: </p> <p>Based on Sotirios's comment, I changed the code to the following: </p> <pre><code>@RequestMapping(value = "/catowners", method = RequestMethod.GET) public String findOwnersOfPetType(BindingResult result, Map&lt;String, Object&gt; model) { // find owners of a specific type of pet Integer typeID = 1;//this is just a placeholder Collection&lt;Owner&gt; results = this.clinicService.findOwnerByPetType(typeID); model.put("selections", results); return "owners/catowners"; } </code></pre> <p>I am still getting the same error message after telling eclipse to run as...run on server again. </p> <p>Is there something that I am not understanding?</p>
    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.
 

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