jsp - org.springframework.beans.NotReadablePropertyException: Invalid property 'idValue' of bean class [java.lang.String]: -


i have dropdown, value of generating in controller , passing value jsp page. getting following exception in "itemvalue" attribute of "form:options" tag. why need getter setter itemvalue because having value "typecode". avoid confusion, added getter setter idvalue also, still getting same error. kindly help.

jsp:

<% map lcclstypecode = (map) request.getattribute("lcclstypecode");  system.out.println("lcclstypecode:"+lcclstypecode); %>  <form:form action="/tradelc/clssave" method="post" onsubmit="return checkpassword()"> . . . . . <form:select path="typecode"> <form:options items="<%=lcclstypecode%>" itemvalue="idvalue" itemlabel="displayvalue"/>        </form:select>  . . . <a href="javascript:submitpagex();">create</a>  <script> function submitpagex()  { document.forms[0].submit();             return false; } 

controller:

@controller @sessionattributes("clsdata") public class informloginaction{ @modelattribute("clsdata")     public clausedata createbean() {         return new clausedata();     }  @requestmapping(value = "/informlogin", method = requestmethod.get)     public modelandview execute( httpservletrequest  request,                                  httpservletresponse response,                                  @modelattribute("clsdata") clausedata clausedata,                                  bindingresult bindingresult)         throws exception { . . . . map newmap = new hashmap(); while(enu!=null && enu.hasmoreelements())         { newmap.put(omxcombobean.assignid(item.trim()),omxcombobean.assignvalue(text)); modelandview modelandview = new modelandview();         modelandview.setviewname("menu1");         modelandview.addobject("command", new clausedata());//specifying bean         modelandview.addobject("lcclstypecode", newmap);//specifying value dropdown         return modelandview; } } 

omxcombobean.java:

public string assignid(string id)     {         idvalue = id;         return id;     }      public string assignvalue(string value)     {         displayvalue = value;         return value;     } 

bean class clausedata.java:

public class clausedata { private string typedesc; private string idvalue; public string gettypecode(){return typecode;}     public void settypecode(string typecode){this.typecode = typecode;} public string getidvalue(){return idvalue;}     public void setidvalue(string idvalue){this.idvalue = idvalue;} } 

exception:

org.springframework.beans.notreadablepropertyexception: invalid property 'idvalue' of bean class [java.lang.string]: bean property 'idvalue' not readable or has invalid getter method: return type of getter match parameter type of setter?     org.springframework.beans.beanwrapperimpl.getpropertyvalue(beanwrapperimpl.java:723)     org.springframework.beans.beanwrapperimpl.getpropertyvalue(beanwrapperimpl.java:714)     org.springframework.web.servlet.tags.form.optionwriter.renderfrommap(optionwriter.java:166)     org.springframework.web.servlet.tags.form.optionwriter.writeoptions(optionwriter.java:136)     org.springframework.web.servlet.tags.form.optionstag.writetagcontent(optionstag.java:155)     org.springframework.web.servlet.tags.form.abstractformtag.dostarttaginternal(abstractformtag.java:84) 

your controller should this

@requestmapping(value = "/informlogin", method = requestmethod.get) public modelandview execute(httpservletrequest  request,httpservletresponse response,@modelattribute("clsdata") clausedata clausedata,bindingresult bindingresult, modelmap model) throws exception {     model.addattribute("command", clausedata); // not modelandview.addobject     model.addattribute("lcclstypecode", map);     ...     return new modelandview("view name"); } 

and here jsp page

<form:form action="/tradelc/clssave" method="post" onsubmit="return checkpassword()" path="command"> ... <form:select path="idvalue">     <form:options items="${lcclstypecode}"/>   <!-- should not use scriptlet , once map has been attached modelmap don't need retrive mannually scriptlet -->     </form:select> ... <a href="javascript:submitpagex();">create</a> 


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -