java - Error populating dropdown list from database - spring mvc - hibernate -


i new java , trying write application using spring-mvc , hibernate.

i getting error "caused by: java.lang.illegalstateexception: neither bindingresult nor plain target object bean name 'command' available request attribute" in jsp file when try populate dropdown list elements database

@controller  public class metalcontroller {       @autowired     mtmetalservice mtmetalservice;      @autowired      mtformulaservice mtformulaservice;      @requestmapping(value = "/", method = requestmethod.get)     public modelandview homepage() {          modelandview model =new modelandview("homepage");          return model;     }      @requestmapping(value = "/inputmetal.html",  method = requestmethod.get)     public modelandview metalinputform() {         mtformula mtformula = new mtformula();         list<mtformula> formulalist = mtformulaservice.getall(mtformula);          modelandview model =new modelandview("metalinput");         model.addobject(formulalist);          (mtformula x: formulalist) {              system.out.println(x.getformulacode());         }         return model;     }      @requestmapping(value = "/metalviewinput.html",  method = requestmethod.get)     public modelandview metalviewform() {          modelandview model =new modelandview("metalviewinput");          return model;     }      @requestmapping(value="/createmetal.html", method = requestmethod.post)     public modelandview createmetal(@modelattribute("mtmetal") mtmetal mtmetal) {          mtmetalservice.persist(mtmetal);         modelandview model =new modelandview("redirect:/inputmetal.html?success=true");          return model;      }       @requestmapping(value="/viewmetal.html", method={ requestmethod.get, requestmethod.post})     public modelandview mcmetalview(         @requestparam("metalcode") string metalcode) {          mtmetal mtmetal = new mtmetal();         mtmetal = mtmetalservice.getone(mtmetal, metalcode);         modelandview model =new modelandview("metalview");         model.addobject("msg", "metal input form");         model.addobject(mtmetal);          return model;     }      @requestmapping(value = "/metallist.html", method={ requestmethod.get})                        public modelandview metallistview() {          mtmetal mtmetal = new mtmetal();         list<mtmetal> mtmetallist = mtmetalservice.getall(mtmetal);         modelandview model = new modelandview("metallistview");         model.addobject(mtmetallist);          return  model;     } }    <%@ page language="java" contenttype="text/html; charset=utf-8"  pageencoding="utf-8"%>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  <%@ taglib prefix="form" uri="http://www.springframework.org ags/form"%>  <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>    <form:form  method="post" action="/labcontrol/createmetal.html">    <c:if test="${param.success eq true}"></c:if> metal save - successful  <table border=1>          <tr><th>metal details entry form</th></tr>         <tr><td>metal code1              </td><td> <input type=text               name="metalcode"/></td></tr>         <tr><td>metal description        </td><td> <input type=text            name="metaldesc"/></td></tr>         <tr><td>metal unit of measure    </td><td> <input type=text          name="metalunit"/></td></tr>               <tr><td>loss formula             </td><td><form:select          path="formulalist">                                                         <form:option          value="-" label="--please select"/>                                                         <form:options          items="${formulalist}" itemvalue="formulacode"          itemlabel="formula"/>                                             </form:select> </td></tr>          <tr><td>treatment recovery       </td><td> <input type=number          name="treatmentrecovery"/></td></tr>         <tr><td>salable mass             </td><td> <input type=number          name="saleablemass"/></td></tr>         <tr><td>pricing unit             </td><td> <input type=number          name="priceperunit"/></td></tr>         <tr><td>gross value              </td><td> <input type=number          name="grossvalue"/></td></tr>       <tr><td><input type="submit" value="save record"></td></tr>          </table>       </form:form> 

 <%@ page language="java" contenttype="text/html; charset=utf-8"  pageencoding="utf-8"%>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  <%@ taglib prefix="form" uri="http://www.springframework.org ags/form"%>  <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>    <form:form  method="post" action="/labcontrol/createmetal.html">    <c:if test="${param.success eq true}"></c:if> metal save - successful  <table border=1>          <tr><th>metal details entry form</th></tr>         <tr><td>metal code1              </td><td> <input type=text               name="metalcode"/></td></tr>         <tr><td>metal description        </td><td> <input type=text            name="metaldesc"/></td></tr>         <tr><td>metal unit of measure    </td><td> <input type=text          name="metalunit"/></td></tr>               <tr><td>loss formula             </td><td><form:select          path="formulalist">                                                         <form:option          value="-" label="--please select"/>                                                         <form:options          items="${formulalist}" itemvalue="formulacode"          itemlabel="formula"/>                                             </form:select> </td></tr>          <tr><td>treatment recovery       </td><td> <input type=number          name="treatmentrecovery"/></td></tr>         <tr><td>salable mass             </td><td> <input type=number          name="saleablemass"/></td></tr>         <tr><td>pricing unit             </td><td> <input type=number          name="priceperunit"/></td></tr>         <tr><td>gross value              </td><td> <input type=number          name="grossvalue"/></td></tr>       <tr><td><input type="submit" value="save record"></td></tr>          </table>       </form:form>} 

Comments