Spring MVC Neither BindingResult nor plain target object for bean name 'contract'

1

I have a "list.jsp" page that renders the list of a certain entity. I was asked to create a search form on this page:

<form:form role="form" commandName="contrato" servletRelativeAction="/contrato/search" method="POST">
  <div class="form-group">
    <div class="form-group">
      <label for="estabelecimento">
        <spring:message code="estabelecimento" />
      </label>
      <form:select id="estabelecimentos" class="form-control" path="estabelecimento">
        <form:option value="-1" label="-- Selecione --" />
        <form:options items="${estabelecimentos}" itemLabel="nomeFantasia" itemValue="id" />
      </form:select>
    </div>
  </div>
  <button type="submit" class="btn btn-success">
    <spring:message code="pesquisar" />
  </button>
  <button type="reset" class="btn btn-default">
    <spring:message code="limpar" />
  </button>
</form:form>

My Controller looks like this:

@RequestMapping(value = "/search")
public ModelAndView search(@RequestParam(required = false) Estabelecimento estabelecimento, @RequestParam(defaultValue = "0", required = false) int page) {
    ...
}

With <form:select> presents the exception below, but if I do the search with a String, description for example (slightly changing the search method) works. Can you give me a light?

  

Neither BindingResult nor plain target object for bean name 'contract'

    
asked by anonymous 23.03.2016 / 17:11

0 answers