Spring MVC Neither Bindingresult nor Plain target Object for bean name 'contract'

Asked

Viewed 46 times

1

I have a "list.jsp" page that renders the list of a certain entity. I was asked to create a search form within 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 is like this:

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

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

Neither Bindingresult nor Plain target Object for bean name 'contract'

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.