Saturday 15 September 2012

html - List not getting edited, even when mapping in controller -



html - List not getting edited, even when mapping in controller -

i working on spring-mvc application. have multiple service classes beingness mapped 1 controller class. sort of 'note taking' application. thats reason there many models, services, on 1 webpage. right now, can add together note, delete note, edit not functioning. before when had 1 dao,model,service,controller, edit used work. 404. posting controller , jsp/html file. kindly have look.none of edits work, sense free take 1 of them. any, pointers helpful. controller class :

@controller public class personcontroller { private personservice personservice; private keyactivitiesservice keyactivitiesservice; private kernresourcenservice kernresourcenservice; private wertangebotservice wertangebotservice; private kundenhungenservice kundenhungenservice; private kommservice kommservice; @autowired(required = true) @qualifier(value="personservice") public void setpersonservice(personservice ps){ this.personservice = ps; } @requestmapping(value = "/", method = requestmethod.get) public string listpersons(model model) { model.addattribute("person", new person()); model.addattribute("keyactivities", new keyactivities()); model.addattribute("kernnotices", new kernresourcen()); model.addattribute("wertnotices", new wertangebot()); model.addattribute("kundnotices", new kundenhungen()); model.addattribute("kommnotices", new kommunikationnotice()); model.addattribute("listpersons", this.personservice.listpersons()); model.addattribute("listnotices", this.keyactivitiesservice.listnotices()); model.addattribute("listkernnotices", this.kernresourcenservice.listkernnotices()); model.addattribute("listwertnotices", this.wertangebotservice.listwertnotices()); model.addattribute("listkundnotices", this.kundenhungenservice.listkundnotices()); model.addattribute("listkommnotices", this.kommservice.listkommnotices()); homecoming "person"; } //for add together , update person both @requestmapping(value= "/person/add", method = requestmethod.post) public string addperson(@modelattribute("person") person p){ //new person, add together this.personservice.addperson(p); homecoming "redirect:/"; } @requestmapping("/remove/{id}") public string removeperson(@pathvariable("id") integer id){ this.personservice.removeperson(id); homecoming "redirect:/"; } @requestmapping("/edit/{id}") public string editperson(@pathvariable("id") integer id, model model){ model.addattribute("person", this.personservice.getpersonbyid(id)); model.addattribute("listpersons", this.personservice.listpersons()); homecoming "person"; } // here start keyactivities controller @autowired(required = true) @qualifier(value="keyactivitiesservice") public void setkeyactivitiesservice(keyactivitiesservice keyactivitiesservice){this.keyactivitiesservice = keyactivitiesservice;} // @requestmapping(value = "/keynotice/listnotices", method = requestmethod.get) public string listkeynotices(model model) { model.addattribute("keyactivities", new keyactivities()); model.addattribute("listnotices", this.keyactivitiesservice.listnotices()); homecoming "keyactivities"; } //for add together , update person both @requestmapping(value= "/keynotice/add", method = requestmethod.post) public string addkeynotice(@modelattribute("keyactivities") keyactivities p){ //new person, add together this.keyactivitiesservice.addkeynotice(p); homecoming "redirect:/"; } @requestmapping("/removenotice/{id}") public string removekeynotice(@pathvariable("id") integer id){ this.keyactivitiesservice.removenotice(id); homecoming "redirect:/"; } @requestmapping("/editnotice/{id}") public string editkeynotice(@pathvariable("id") integer id, model model){ model.addattribute("keyactivities", this.keyactivitiesservice.getnoticebyid(id)); model.addattribute("keyactivities", this.keyactivitiesservice.listnotices()); homecoming "keyactivities"; } //kernesourcen starts @autowired(required = true) @qualifier(value = "kernresourcenservice") public void setkernresourcenservice(kernresourcenservice kernresourcenservice){this.kernresourcenservice = kernresourcenservice;} // @requestmapping(value = "/kernnotice/listkernnotices", method = requestmethod.get) public string listkernnotices(model model) { model.addattribute("kernnotices", new kernresourcen()); model.addattribute("listkernnotices", this.kernresourcenservice.listkernnotices()); homecoming "kernnotices"; } //for add together , update person both @requestmapping(value= "/kernnotice/add", method = requestmethod.post) public string addkernnotice(@modelattribute("kernnotices") kernresourcen p){ //new person, add together this.kernresourcenservice.addkernnotice(p); homecoming "redirect:/"; } @requestmapping("/removekernnotice/{id}") public string removekernnotice(@pathvariable("id") integer id){ this.kernresourcenservice.removekernnotice(id); homecoming "redirect:/"; } @requestmapping("/editkernnotice/{id}") public string editkernnotice(@pathvariable("id") integer id, model model){ model.addattribute("kernnotices", this.kernresourcenservice.getkernnoticenbyid(id)); model.addattribute("kernnotices", this.kernresourcenservice.listkernnotices()); homecoming "kernnotices"; } // wertangebot controller starts here @autowired(required = true) @qualifier(value = "wertnoticesservice") public void setwertangebotservice(wertangebotservice wertangebotservice){this.wertangebotservice = wertangebotservice;} // @requestmapping(value = "/wertnotice/listwertnotice", method = requestmethod.get) public string listwertnotices(model model) { model.addattribute("wertnotices", new wertangebot()); model.addattribute("listwertnotices", this.wertangebotservice.listwertnotices()); homecoming "wertnotices"; } //for add together , update person both @requestmapping(value= "/wertnotice/add", method = requestmethod.post) public string addwertnotice(@modelattribute("wertnotices") wertangebot p){ //new person, add together this.wertangebotservice.addwertnotice(p); homecoming "redirect:/"; } @requestmapping("/removewertnotice/{id}") public string removewertnotice(@pathvariable("id") integer id){ this.wertangebotservice.removewertnotice(id); homecoming "redirect:/"; } @requestmapping("/editwertnotice/{id}") public string editwertnotice(@pathvariable("id") integer id, model model){ model.addattribute("wertnotices", this.wertangebotservice.getwertnoticenbyid(id)); model.addattribute("wertnotices", this.wertangebotservice.listwertnotices()); homecoming "wertnotices"; } //kundenhungen controller starts here @autowired(required = true) @qualifier(value = "kundenhungenservice") public void setkundenhungenservice(kundenhungenservice kundenhungenservice){this.kundenhungenservice=kundenhungenservice;} // @requestmapping(value = "/wertnotice/listwertnotice", method = requestmethod.get) public string listkundnotices(model model) { model.addattribute("kundnotices", new kundenhungen()); model.addattribute("listkundnotices", this.kundenhungenservice.listkundnotices()); homecoming "kundnotices"; } //for add together , update person both @requestmapping(value= "/kundnotice/add", method = requestmethod.post) public string addkundnotice(@modelattribute("kundnotices") kundenhungen p){ //new person, add together this.kundenhungenservice.addkundnotice(p); homecoming "redirect:/"; } @requestmapping("/removekundnotice/{id}") public string removekundnotice(@pathvariable("id") integer id){ this.kundenhungenservice.removekundnotice(id); homecoming "redirect:/"; } @requestmapping("/editkundnotice/{id}") public string editkundnotice(@pathvariable("id") integer id, model model){ model.addattribute("kundnotices", this.kundenhungenservice.getkundnoticebyid(id)); model.addattribute("kundnotices", this.kundenhungenservice.listkundnotices()); homecoming "kundnotices"; } //kommunikationsnotice controller starts here. @autowired(required = true) @qualifier(value = "kommservice") public void setkommservice(kommservice kommservice){this.kommservice=kommservice;} // @requestmapping(value = "/wertnotice/listwertnotice", method = requestmethod.get) public string listkommnotices(model model) { model.addattribute("kommnotices", new kommunikationnotice()); model.addattribute("listkommnotices", this.kommservice.listkommnotices()); homecoming "kommnotices"; } //for add together , update person both @requestmapping(value= "/kommnotice/add", method = requestmethod.post) public string addkommnotice(@modelattribute("kommnotices") kommunikationnotice p){ //new person, add together this.kommservice.addkommnotice(p); homecoming "redirect:/"; } @requestmapping("/removekommnotice/{id}") public string removekommnotice(@pathvariable("id") integer id){ this.kommservice.removekommnotice(id); homecoming "redirect:/"; } @requestmapping("/editkommnotice/{id}") public string editkommnotice(@pathvariable("id") integer id, model model){ model.addattribute("kommnotices", this.kommservice.getkommnoticebyid(id)); model.addattribute("kommnotices", this.kommservice.listkommnotices()); homecoming "kommnotices"; } }

jsp file

<c:url var="addaction" value="/person/add" ></c:url> <form:form action="${addaction}" commandname="person"> <table> <c:if test="${!empty person.name}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="name"> <spring:message text="name"/> </form:label> </td> <td> <form:input path="name" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty person.name}"> <input type="submit" value="<spring:message text="edit partner"/>" /> </c:if> <c:if test="${empty person.name}"> <input type="submit" value="<spring:message text="add partner"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>partners list</h3> <c:if test="${!empty listpersons}"> <table class="tg"> <tr> <th width="120">partner name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listpersons}" var="person"> <tr> <td>${person.name}</td> <td><a href="<c:url value='/edit/${person.id}' />" >edit</a></td> <td><a href="<c:url value='/remove/${person.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if> <br> <c:url var="addaction" value="/keynotice/add" ></c:url> <form:form action="${addaction}" commandname="keyactivities"> <table> <c:if test="${!empty keyactivities.keynotice}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="keynotice"> <spring:message text="keynotice"/> </form:label> </td> <td> <form:input path="keynotice" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty keyactivities.keynotice}"> <input type="submit" value="<spring:message text="edit kernaktivitaten"/>" /> </c:if> <c:if test="${empty keyactivities.keynotice}"> <input type="submit" value="<spring:message text="add kernaktivitaten"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>kernaktivaten list</h3> <c:if test="${!empty listnotices}"> <table class="tg"> <tr> <th width="120">kernaktivaten name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listnotices}" var="keyactivities"> <tr> <td>${keyactivities.keynotice}</td> <td><a href="<c:url value='/editnotice/${keyactivities.id}' />" >edit</a></td> <td><a href="<c:url value='/removenotice/${keyactivities.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if> <c:url var="addaction" value="/kernnotice/add" ></c:url> <form:form action="${addaction}" commandname="kernnotices"> <table> <c:if test="${!empty kernnotices.kernresourcennotice}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="kernresourcennotice"> <spring:message text="kernresourcennotice"/> </form:label> </td> <td> <form:input path="kernresourcennotice" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty kernnotices.kernresourcennotice}"> <input type="submit" value="<spring:message text="edit kernnotice"/>" /> </c:if> <c:if test="${empty person.name}"> <input type="submit" value="<spring:message text="add kernnotice"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>kernensourcen list</h3> <c:if test="${!empty listkernnotices}"> <table class="tg"> <tr> <th width="120">kernnotice name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listkernnotices}" var="kernnotices"> <tr> <td>${kernnotices.kernresourcennotice}</td> <td><a href="<c:url value='/editkernnotice/${kernnotices.id}' />" >edit</a></td> <td><a href="<c:url value='/removekernnotice/${kernnotices.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if> <c:url var="addaction" value="/wertnotice/add" ></c:url> <form:form action="${addaction}" commandname="wertnotices"> <table> <c:if test="${!empty wertnotices.wertangebotnotice}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="wertangebotnotice"> <spring:message text="wertangebotnotice"/> </form:label> </td> <td> <form:input path="wertangebotnotice" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty wertnotices.wertangebotnotice}"> <input type="submit" value="<spring:message text="edit wertnotice"/>" /> </c:if> <c:if test="${empty wertnotices.wertangebotnotice}"> <input type="submit" value="<spring:message text="add wertnotice"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>wertangebot list</h3> <c:if test="${!empty listwertnotices}"> <table class="tg"> <tr> <th width="120">wertnotice name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listwertnotices}" var="wertnotices"> <tr> <td>${wertnotices.wertangebotnotice}</td> <td><a href="<c:url value='/editwertnotice/${wertnotices.id}' />" >edit</a></td> <td><a href="<c:url value='/removewertnotice/${wertnotices.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if> <c:url var="addaction" value="/kundnotice/add" ></c:url> <form:form action="${addaction}" commandname="kundnotices"> <table> <c:if test="${!empty kundnotices.kundennotice}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="kundennotice"> <spring:message text="kundennotice"/> </form:label> </td> <td> <form:input path="kundennotice" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty kundnotices.kundennotice}"> <input type="submit" value="<spring:message text="edit kundennotice"/>" /> </c:if> <c:if test="${empty kundnotices.kundennotice}"> <input type="submit" value="<spring:message text="add kundennotice"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>kundennotices list</h3> <c:if test="${!empty listkundnotices}"> <table class="tg"> <tr> <th width="120">kundennotice name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listkundnotices}" var="kundennotices"> <tr> <td>${kundennotices.kundennotice}</td> <td><a href="<c:url value='/editkundnotice/${kundennotices.id}' />" >edit</a></td> <td><a href="<c:url value='/removekundnotice/${kundennotices.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if> <c:url var="addaction" value="/kommnotice/add" ></c:url> <form:form action="${addaction}" commandname="kommnotices"> <table> <c:if test="${!empty kommnotices.kommnotice}"> <tr> <td> <form:label path="id"> <spring:message text="id"/> </form:label> </td> <td> <form:input path="id" readonly="true" size="8" disabled="true" /> <form:hidden path="id" /> </td> </tr> </c:if> <tr> <td> <form:label path="kommnotice"> <spring:message text="kommnotice"/> </form:label> </td> <td> <form:input path="kommnotice" /> </td> </tr> <tr> <td colspan="1"> <c:if test="${!empty kommnotices.kommnotice}"> <input type="submit" value="<spring:message text="edit kommnotice"/>" /> </c:if> <c:if test="${empty kommnotices.kommnotice}"> <input type="submit" value="<spring:message text="add kommnotice"/>" /> </c:if> </td> </tr> </table> </form:form> <h3>kommnotices list</h3> <c:if test="${!empty listkommnotices}"> <table class="tg"> <tr> <th width="120">kommnotices name</th> <th width="60">edit</th> <th width="60">delete</th> </tr> <c:foreach items="${listkommnotices}" var="kommnotices"> <tr> <td>${kommnotices.kommnotice}</td> <td><a href="<c:url value='/editkommnotice/${kommnotices.id}' />" >edit</a></td> <td><a href="<c:url value='/removekommnotice/${kommnotices.id}' />" >delete</a></td> </tr> </c:foreach> </table> </c:if>

url links 404 on edit :

http://localhost:8085/mvcmanage-1.0-snapshot/editnotice/300 http://localhost:8085/mvcmanage-1.0-snapshot/editkernnotice/200 http://localhost:8085/mvcmanage-1.0-snapshot/editwertnotice/150 http://localhost:8085/mvcmanage-1.0-snapshot/editkundnotice/250 http://localhost:8085/mvcmanage-1.0-snapshot/editkommnotice/200

for above, 404

new error log : (after clicking on edit person)

severe: servlet.service() servlet [appservlet] in context path [] threw exception [an exception occurred processing jsp page /web-inf/views/person.jsp @ line 380 377: </c:if> 378: <tr> 379: <td> 380: <form:label path="keynotice"> 381: <spring:message text="keynotice"/> 382: </form:label> 383: </td> stacktrace:] root cause java.lang.illegalstateexception: neither bindingresult nor plain target object bean name 'keyactivities' available request attribute @ org.springframework.web.servlet.support.bindstatus.<init>(bindstatus.java:144) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getbindstatus(abstractdataboundformelementtag.java:168) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getpropertypath(abstractdataboundformelementtag.java:188) @ org.springframework.web.servlet.tags.form.labeltag.autogeneratefor(labeltag.java:130) @ org.springframework.web.servlet.tags.form.labeltag.resolvefor(labeltag.java:120) @ org.springframework.web.servlet.tags.form.labeltag.writetagcontent(labeltag.java:90) @ org.springframework.web.servlet.tags.form.abstractformtag.dostarttaginternal(abstractformtag.java:84) @ org.springframework.web.servlet.tags.requestcontextawaretag.dostarttag(requestcontextawaretag.java:80) @ org.apache.jsp.web_002dinf.views.person_jsp._jspx_meth_form_005flabel_005f3(person_jsp.java:1969) @ org.apache.jsp.web_002dinf.views.person_jsp._jspx_meth_form_005fform_005f1(person_jsp.java:1740) @ org.apache.jsp.web_002dinf.views.person_jsp._jspservice(person_jsp.java:395) @ org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:432) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:390) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:334) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.applicationdispatcher.invoke(applicationdispatcher.java:748) @ org.apache.catalina.core.applicationdispatcher.processrequest(applicationdispatcher.java:486) @ org.apache.catalina.core.applicationdispatcher.doforward(applicationdispatcher.java:411) @ org.apache.catalina.core.applicationdispatcher.forward(applicationdispatcher.java:338) @ org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:209) @ org.springframework.web.servlet.view.abstractview.render(abstractview.java:267) @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1221) @ org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1005)

generally, these mutual reasons getting 404 spring mvc:

wrong controller mapping (url or request method) view returned controller method can't found some of <jsp:include > dependencies main view can't found (this goes whole include chain)

check if have issue of these.

html spring spring-mvc

No comments:

Post a Comment