I'm trying to injection a dependency in my controller, instead using setters methods, but it didnot work .
What do I want to do ?. Just bind domain model with my form using springframework 3.1, in a controller class
My domain class:
public class person {name of private string; @ Owned public person (name of string) {this.name = name; } Public string getName () {this.name; }} My JSP (person-received):
& lt; Form action = "test-person" method = "post" & gt; & Lt; Table cellpadding = "0" cellspacing = "0" align = "center" & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; P & gt; Name: & lt; / B & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Input type = "text" id = "name" name = "name" & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; My Controller:
@controller public class person coordinator {@RequestMapping (value = "test-person", method = RequestMethod.GET) public string LoadVisible () {return "person-received"; } @RequestMapping (value = "test-person", method = RequestMethod.POST) Public string doPost (person, model model) {model.addAttribute ("person", person); Return "person-post"; }} and the name entered by the user (person-post) is shown as the previous jsp:
& Lt; / TR & gt; & Lt; / Table & gt; Throwed exception:
java.lang.NoSuchMethodException:. Models.Person & LT; Init & gt; () Org.springframework.web.method.annotation java.lang.Class.getConstructor0 (Unknown Source) java.lang.Class.getDeclaredConstructor (Unknown Source) org.springframework.beans.BeanUtils.instantiateClass (BeanUtils.java:104). Modelatrybutemethodaprosessorkkreatittri Butte (Modelatrybutemethodaprosessorkjawa:l32) Orgkspringfrmevorkkvebksserwletkmvkkmethdkantsnksserwletmodelatrybutemethodapr. Okessorkkreateattribute (Sserwletmodelatrybutemethodaprosessorkjawa:8l) Orgkspringfrmevorkkvebkmethdkannoteshnkmodelatrybutemethodaprosessorkresolveargu assessment (Modelatrybutemethodaprosessorkjawa:l03) Orgkspringfrmevork. Web.method.support.HandlerMethodArgumentResolverComposite.resol veArgument (HandlerMethodArgumentResolverComposite.java:75) org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValu es (InvocableHandlerMethod.java:156) org.springframework.web.method.s Upport.InvocableHandlerMethod .invokeForRequest (Invo cableHandlerMethod.java117) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod. Invokeawrhndl (Srwletanuvrniyhandlr Vidhikjawa: 96) org.springframework.web.servlet.mvc.method.annotation .RequestMappingHandlerAdapter. Invokehndlermethoda (Rekvestmappingndleradpterkjawa:6l7) Orgkspringfrmevorkkvebksserwletkmvkkmethdkannoteshnkrekvestmappingndleradpter. HandleInternal (RequestMappingHandlerAdapter.javaEND_BOLD78) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle (Abst ractHandlerMethodAdapter.java:80) org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java: 923) Organization .springframework .web.servlet.DispatcherServlet.doService (DispatcherServlet.java: 852) org.springframework.web.servlet.FrameworkServlet.processRequest (Fremvrksrwletkja VA: 882) org.springframework.web.servlet.FrameworkServlet.doPost (framework server. Java 789) Jvksksserwlet.actiteepikhttpsserwletksrvis (Httpsserwletkjawa:64l) Jvksksserwlet.actiteepikhttpsserwletksrvis (Httpsserwletkjawa:722) Brkgovkspkmkokakfiltroskfiltrodoneksaokdofiltr (Filtrodoneksao .java.3) I think spring is a default constructor whitout parameter Why is hapenning is looking for s that?
Thank you! The
After the
The manufacturer injections need to have bean a spring in your spring-reference with your bean or an annotation form.
However, I doubt that it will pass a parameter as a manufacturer to be used as Farmetr. The parameters should be set with the spring setters. Use the standard manufacturer and add a setter.
No comments:
Post a Comment