jsp - Form inheritance in Spring MVC -


i facing situation in spring mvc application have form common pages. so, took form in separate jsp page , included page in other jsp pages. form simple:

   <form:form method="post" commandname="coachingdomain" action="searchform">      <form:input path="coachingname" placeholder="search coaching" />      <button type="submit" value="search">search</button> </form:form>     

now scene when run application, server not able find binding of coachingdomain in controller. make more clear, suppose form present in page a1 , included in page a2. in a2 controller, have bind coachingdomain given below:

  @requestmapping(method = requestmethod.get) public string showpage(modelmap modelmap, httpservletrequest request,         httpservletresponse response) {     modelmap.addattribute("coachingdomain",             new coachingdomain());     return "welcome"; } 

but bind error still appeared. seems me server trying find controller of a1 page first. so, created a1 controller (as abstract) , made a2 extend a1 controller. then, placed same code in a1. still same error there.

my a1 , a2 controllers are:

   public abstract class a1 {  public void showpage1(modelmap modelmap, httpservletrequest request,         httpservletresponse response) {     system.out.println("a1 called");     modelmap.addattribute("coachingdomain",             new coachingdomain());      }  }    @controller   @requestmapping(value = "/a2.html")  public class a2 extends a1 {  @requestmapping(method = requestmethod.get) public string showpage(modelmap modelmap, httpservletrequest request,         httpservletresponse response) {     system.out.println("a2 called");             showpage1(modelmap, request, response);     modelmap.addattribute("searchcoachingdomain",             new searchcoachingdomain());     return "a2";      }    } 

my jsp pages are:

a1.jsp:

    <body>    <form:form method="post" commandname="coachingdomain" action="searchform">      <form:input path="coachingname" placeholder="search coaching" />      <button type="submit" value="search">search</button> </form:form>       </body> 

a2.jsp:

<%@include file="/web-inf/views/root.jsp"%> 

and error is:

       neither bindingresult nor plain target object bean name 'coachingdomain' available request attribute @ org.springframework.web.servlet.support.bindstatus.<init>(bindstatus.java:141) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getbindstatus(abstractdataboundformelementtag.java:174) 

there inheritance examples given in internet not able make how to make form common jsp pages. 1 approach think of may using javascript bind submit button js function , make call required url. hoping if same can achieved using spring mvc @requestmapping(method = requestmethod.post) technique. please suggest me out here...


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -