Announcement Announcement Module
Collapse
No announcement yet.
Neither BindingResult nor plain target object for bean name 'command' available Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neither BindingResult nor plain target object for bean name 'command' available

    Hi all,

    I use a SimpleFormController (in spring 2.0.3) to use a search criteria named email, then do the search and return the results model to the same jsp page where I display the results list.

    In SimpleFormController I have implemented the onSubmit() method.
    Code:
    protected ModelAndView onSubmit(Object command) throws Exception{
    Map model = getService().search(command); model.put("command", command); return new ModelAndView(viewName, modelName, model);
    }
    On the same jsp page, I have the form and the list of records display. It looks like follows.

    Code:
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    ......
    <form:form method="post">Email: <form:input path="email" /> 
    <INPUT type="submit" /></form:form>
    ......
    <!-- displaying part-->
    I do not use any validations or error messages in the form.

    My jsp gets loaded correctly, but when I do the search following exception is thrown.

    Is it a must to use validations? How can I avoid this error?

    - Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    at org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:137)
    at org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getBindStatus(AbstractData BoundFormElementTag.java:179)
    at org.springframework.web.servlet.tags.form.Abstract HtmlElementTag.resolveCssClass(AbstractHtmlElement Tag.java:502)
    at org.springframework.web.servlet.tags.form.Abstract HtmlElementTag.writeDefaultAttributes(AbstractHtml ElementTag.java:479)
    at org.springframework.web.servlet.tags.form.Abstract HtmlInputElementTag.writeDefaultAttributes(Abstrac tHtmlInputElementTag.java:171)
    at org.springframework.web.servlet.tags.form.InputTag .writeTagContent(InputTag.java:175)
    at org.springframework.web.servlet.tags.form.Abstract FormTag.doStartTagInternal(AbstractFormTag.java:90 )
    at org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:7 7)
    at org.apache.jsp.WEB_002dINF.jsp.customerSearchRecor ds_jsp._jspx_meth_form_input_0(customerSearchRecor ds_jsp.java:153)
    at org.apache.jsp.WEB_002dINF.jsp.customerSearchRecor ds_jsp._jspx_meth_form_form_0(customerSearchRecord s_jsp.java:119)
    at org.apache.jsp.WEB_002dINF.jsp.customerSearchRecor ds_jsp._jspService(customerSearchRecords_jsp.java: 78)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:334)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:672)
    at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:463)
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:398)
    at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:301)
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:142)
    at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:247)
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1103)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:840)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:754)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:399)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:364)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)

  • #2
    Originally posted by lkamal View Post
    Is it a must to use validations? How can I avoid this error?
    No, validation is not a must. But you must not break the default method calls of Spring controller hierarchy Actually it's your

    Code:
    protected ModelAndView onSubmit(Object command) throws Exception {
      Map model = getService().search(command);
      model.put("command", command);
      return new ModelAndView(viewName, modelName, model);
    }
    changing the default Spring behaviour by returning a "wrong" model.

    What you need to do is not to set up your own model map, but to reuse the existing one and to inject your result.

    I have implemented a RedisplayingSearchFormController in which I return the result as part of referenceData.

    Code:
    protected Map referenceData(HttpServletRequest request,
                                Object command,
                                Errors errors) throws Exception {
      Map referenceData = new HashMap();
      Object result = getResult(request, command, errors);
      referenceData.put("result", result);
      return referenceData;
    }
    
    protected abstract Object getResult(HttpServletRequest request,
                                        Object command,
                                        Errors errors) throws Exception;
    The important part is hidden in Spring's controller hierarchy: The model MUST be retrieved by errors.getModel() - otherwise you have to set up your model exactly in that way Spring does it or you get the exception you observed.

    Hope that gets you the idea.

    Jörg

    Comment


    • #3
      Thanks Heinicke for the quick reply.

      But I have some concerns with ur answer as I'm new to Spring MVC.

      1.
      But you must not break the default method calls of Spring controller hierarchy Actually it's your code changing the default Spring behaviour by returning a "wrong" model.
      As I have read and learned (according to Spring in Action book as well), when you have to forward the user to a display page as the successView after a form submit, you have to implement the onSubmit(Object command, BindException e) method rather than the onSubmitAction().

      Code:
      public ModelAndView onSubmit(Object command, BindException e){
      ---- return new ModelAndView(getSuccessView(), "modelName", model)
      }
      2. Is the data returned from the referenceData() method automatically get available inside the jsp page. How can those data be accessed?

      Thanks in advance.

      Comment


      • #4
        Originally posted by lkamal View Post
        As I have read and learned (according to Spring in Action book as well), when you have to forward the user to a display page as the successView after a form submit, you have to implement the onSubmit(Object command, BindException e) method rather than the onSubmitAction().
        I do not really understand your concern here or how it refers to my post. I did not touch the submit handling at all. With the method you overwrite in your code (onSubmit(Object command)) you change the default behaviour of Spring - and that's your problem. There are only different solutions to solve it.

        Btw, the default hook for submits is doSubmitAction(Object command). But this method is of return type void, so you can't do anything with your search result.

        Originally posted by lkamal View Post
        Is the data returned from the referenceData() method automatically get available inside the jsp page. How can those data be accessed?
        Yes, it is - in the form view, but not the success view (should have mentioned this). The idea of my RedisplayingSearchFormController is indeed to show the form view again after a submit and not the success view as you normally just change the search criteria and submit the form again.

        It is accessible in the JSP just by using it's key in the map; in the example I made above by using "result".

        If you don't want to go the RedisplayingSearchFormController way you might implement onSubmit(Object command, BindException errors) in the following way:

        Code:
        protected ModelAndView onSubmit(Object command, BindException errors) throws Exception {
          Object searchResult = getService().search(command);
          Map model = errors.getModel();
          model.put("result", searchResult);
          return super.onSubmit(command, errors);
        }
        In that way you don't break the default method call flow of the Spring controller hierarchy, but you only modify the model to your needs. As in my RedisplayingSearchFormController the search result is available in the JSP by using "result".

        Jörg

        Comment


        • #5
          Thanks for the comments. I have corrected the errors that I was doing.

          But still I have some issue. (Sorry for bothering too much).

          Code:
          protected ModelAndView onSubmit(
                    HttpServletRequest request, HttpServletResponse response,                                                                         
                    Object command, BindException errors) throws Exception {
              
              prForm(request, response, errors.getModel(), command);	
              return super.onSubmit(request, response, command, errors);
          }
          
          public void prForm(
                    HttpServletRequest request, HttpServletResponse response,                                                                         
                    Map model, Object command) throws Exception {
          	
               model.put("testValue", "Test Value");
          }
          Now no errors occur as I'm using the Model returned from the errors object.

          But still I can not access this Model from the jsp. My jsp is as follows.

          Code:
          <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
          <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
          <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
          
          <form:form method="post">Email: <form:input path="email" /> 
          <INPUT type="submit" /></form:form>
          
          <c:if test="${testValue}" >
          	<c:out value="${testValue}" />
          </c:if>
          Non of these two prints the value since the model name. So the data inside the Model is not available just through the keys (without the model name).

          But when I was using the previous methodology of creating a new ModelAndView object with;

          new ModelAndView("viewName", "modelName", model);

          I could access the data by as follows.
          Code:
          <c:out value="${modelName.testValue}" />
          Am I doing anything wrong here?

          Comment


          • #6
            Originally posted by lkamal View Post
            (Sorry for bothering too much)
            No problem. If it were too much bothering I would just stop answering

            Your questions are absolutely valid - and I might learn from them as well.

            Originally posted by lkamal View Post
            Now no errors occur as I'm using the Model returned from the errors object. But still I can not access this Model from the jsp. [..] Am I doing anything wrong here?
            You make me a bit clueless. It should work.

            I can't see a difference at the end between your working code and the one with the model map. Just have a view at the ModelAndView constructors and the ModelMap that gets instantiated. With the default code ModelMap.addAllObjects(Map) (with Map being the one from errors.getModel()) is called, with your one ModelMap.addObject(modelName, modelObject) (calling Map.putAll(Map) and Map.put(key, value)).

            Can you debug the code and have a look at the ModelMap and how it is different from the objects in it?

            Jörg

            Comment


            • #7
              answer Neither BindingResult nor plain target object for bean name 'command' availab

              If you are using a controller and
              your context path does not supported by controller
              you can get this message
              if you have a controller this controller does not have this attribute

              at Spring referance this described clearly

              The ControllerClassNameHandlerMapping finds all of the various handler (or Controller) beans defined in its application context and strips 'Controller' off the name to define its handler mappings.

              Let's look at some more examples so that the central idea becomes immediately familiar.

              *

              WelcomeController maps to the '/welcome*' request URL
              *

              HomeController maps to the '/home*' request URL
              *

              IndexController maps to the '/index*' request URL
              *

              RegisterController maps to the '/register*' request URL
              *

              DisplayShoppingCartController maps to the '/displayshoppingcart*' request URL

              (Notice the casing - all lowercase - in the case of camel-cased Controller class names.)

              In the case of MultiActionController handler classes, the mappings generated are (ever so slightly) more complex, but hopefully no less understandable. Some examples (all of the Controller names in this next bit are assumed to be MultiActionController implementations).

              *

              AdminController maps to the '/admin/*' request URL
              *

              CatalogController maps to the '/catalog/*' request URL

              If you follow the pretty standard convention of naming your Controller implementations as xxxController, then the ControllerClassNameHandlerMapping will save you the tedium of having to firstly define and then having to maintain a potentially looooong SimpleUrlHandlerMapping (or suchlike).

              The ControllerClassNameHandlerMapping class extends the AbstractHandlerMapping base class so you can define HandlerInterceptor instances and everything else just like you would with many other HandlerMapping implementations.

              Soner Sivri
              From Turkey

              Comment


              • #8
                Inserting into the errors model is not good practice, as it may break depending up the type of DataBinder being used.

                For instance, the AbstractBindingResult#getModel() actually creates a new HashMap. So any changes your adding will be lost because this method will get called again from inside the onSubmit(Object command, BindException errors) method in the SimpleFormController. Thus creating a new HashMap without your model object (which is what is happening here).

                Instead you should add the model object to the ModelAndView after the submit action occurs. So do this instead:

                Code:
                protected ModelAndView onSubmit(
                          HttpServletRequest request, HttpServletResponse response, 
                          Object command, BindException errors) throws Exception {
                    
                    ModelAndView modelAndView = super.onSubmit(request, response, command, errors);
                    prForm(modelAndView);	
                    return modelAndView;
                }
                
                public void prForm(ModelAndView modelAndView) throws Exception {
                	modelAndView.addObject("testValue", "Test Value");
                }
                Now your object should be available to your template.

                Comment


                • #9
                  If for the view form a controller should be used extend the AbstractFormController.
                  Be careful to include the command class in the view like this

                  Code:
                          ModelAndView modelAndView = new ModelAndView("comments");
                          modelAndView.addObject("commentComp", new CommentComp());
                          modelAndView.addObject("model", comments);
                          return modelAndView;

                  Comment


                  • #10
                    Neither BindingResult nor plain target object for bean name 'command' available

                    Did you get this to work? I have been trying to achieve the same jsp (i.e. search and then return the search results to the same jsp), but I'm finding it hard to put the search results into the model for display.

                    I'd like to see how the RedisplayingSearchFormController idea works, could you send me more details? i.e. how do you get two controllers to 'forward' to the same jsp, when I tried this it just gave me binding errors.

                    Comment


                    • #11
                      Hi --

                      Did any body got this working. I have a similar situation where i have a dropdown box in the view page and i would like to display the result on the same view without a different success view. I tried chanching the code based on what was mentioned in the post but still it is not working for me. i am not able to access the values in my main page. since is one know what variable i should be using to display

                      protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
                      Object command, BindException errors) throws Exception {

                      Map htmlout = processInput(request, response,command, errors);
                      Map model = errors.getModel();
                      model.put("htmlout",htmlout );

                      return super.onSubmit(request, response, command, errors);


                      }

                      Also my dropdown is now empty. how do i re-populate the value since the dropdown field.

                      any Help is greatly appreciated
                      thanks
                      Gopi

                      Comment


                      • #12
                        Seems like a fairly big flaw in Spring not to be able to return to the same page and see your updates!

                        Then again this controller has been deprecated. Would anyone care to suggest the proper way to do something like this. Can it be done with a command object?

                        After reading the Spring in Action book cover to cover AND the Spring Docs, I'm none the wiser.

                        Comment


                        • #13
                          What's the recipe, then?

                          http://static.springsource.org/docs/...tep/part4.html shows creating a new model.

                          One expert up in this thread calls for borrowing the error model.

                          Another expert says not to do that; to use another approach altogether.

                          What are we all missing here? It seems simple enough -- to want to handle a submission of one form by adding its results to the model and moving on to the next thing.

                          Comment


                          • #14
                            Same issue here again

                            Hi,
                            I am trying Spring MVC for the first time(in fact I am quite new to Spring also). I tried this so many times for the past one day but still getting the same issue, even after looking at the suggested link and also other google search results. I am using the Spring mvc tutorial available at:

                            http://static.springsource.org/docs/...tep/part4.html

                            Following is the error:

                            Code:
                             org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 16
                            
                            13: &lt;h1&gt;&lt;fmt:message key="heading"/&gt;&lt;/h1&gt;
                            14: 
                            15: &lt;form:form name="searchForm" method="POST" action = "/SearchAccessServlet.do" commandName="searchAccess"&gt;
                            16: &lt;!--&lt;form:input path="kopsId" /&gt;
                            17: &lt;form:errors path="kopsId" cssClass="error"/&gt;--&gt;
                            18: <br><br>
                            19: &lt;input type="submit" value="Submit" /&gt;
                            
                            
                            Stacktrace:
                            	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
                            	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)
                            	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
                            	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
                            	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                            
                            
                            root cause 
                            
                            java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'searchAccess' available as request attribute
                            	org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:141)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:172)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:192)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:158)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:145)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:136)
                            	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:120)
                            	org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
                            	org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
                            	org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
                            	org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
                            	org.apache.jsp.index_jsp._jspx_meth_form_005finput_005f0(index_jsp.java:225)
                            	org.apache.jsp.index_jsp._jspService(index_jsp.java:114)
                            	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
                            	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                            	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
                            	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
                            	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
                            	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                            
                            
                            note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.
                            Following is my web.xml:

                            Code:
                              &lt;?xml version="1.0" encoding="UTF-8"?&gt;
                            &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
                              &lt;display-name&gt;CEDToolkit&lt;/display-name&gt;
                              
                              &lt;context-param&gt;
                                     &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
                                     &lt;param-value&gt;/WEB-INF/log4j.xml&lt;/param-value&gt;
                              &lt;/context-param&gt;
                              &lt;context-param&gt;
                                     &lt;param-name&gt;log4jRefreshInterval&lt;/param-name&gt;
                                     &lt;param-value&gt;1000&lt;/param-value&gt;
                              &lt;/context-param&gt;
                              &lt;listener&gt;
                                    &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
                              &lt;/listener&gt;
                              
                              &lt;listener&gt;  
                                 &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;  
                              &lt;/listener&gt;
                              &lt;context-param&gt;
                                    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;		
                            		&lt;param-value&gt;/WEB-INF/services.xml&lt;/param-value&gt;  
                              &lt;/context-param&gt;
                              
                            
                            &lt;!-- Declare the existence of a servlet. --&gt;
                            
                              &lt;servlet&gt;
                                &lt;servlet-name&gt;Dispatcher&lt;/servlet-name&gt;
                                &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
                                &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
                              &lt;/servlet&gt;
                            
                              &lt;!-- Map URLs to that servlet. --&gt;
                              &lt;servlet-mapping&gt;
                                &lt;servlet-name&gt;Dispatcher&lt;/servlet-name&gt;
                                &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
                              &lt;/servlet-mapping&gt;
                              
                              &lt;welcome-file-list&gt;
                                &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
                              &lt;/welcome-file-list&gt;
                              
                              &lt;jsp-config&gt;
                                &lt;taglib&gt;
                                  &lt;taglib-uri&gt;/spring&lt;/taglib-uri&gt;
                                  &lt;taglib-location&gt;/WEB-INF/tld/spring-form.tld&lt;/taglib-location&gt;
                                &lt;/taglib&gt;
                              &lt;/jsp-config&gt;
                              
                            &lt;/web-app&gt;
                            Contd in next post.

                            Comment


                            • #15
                              Same issue here again

                              Following is the code in services.xml:

                              Code:
                              &lt;?xml version="1.0" encoding="UTF-8"?&gt;
                              
                              &lt;beans xmlns="http://www.springframework.org/schema/beans"
                                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                     xsi:schemaLocation="http://www.springframework.org/schema/beans
                                     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;&lt;!-- Declare the existence of a servlet. --&gt;
                              
                              &lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
                                      &lt;property name="basenames"&gt;
                                      	&lt;list&gt;
                              				&lt;value&gt;CEDToolkit&lt;/value&gt;
                              			&lt;/list&gt;
                              		&lt;/property&gt;
                              &lt;/bean&gt;
                              &lt;bean id="example" class="com.util.PropertyUtil"&gt;
                              	&lt;property name="rbms" ref="messageSource"/&gt;
                              &lt;/bean&gt;
                              
                              &lt;!-- &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
                                              &lt;property name="location"&gt;
                                              	&lt;value&gt;
                                              		classpath:CEDToolkit.properties
                                              	&lt;/value&gt;
                                              &lt;/property&gt;
                              &lt;/bean&gt; --&gt;
                              
                              &lt;bean id="searchAccessServiceImpl" class="com.service.SearchAccessServiceImpl"/&gt;
                              
                              &lt;/beans&gt;
                              Following is the code in Dispatcher-servlet.xml:

                              Code:
                               &lt;?xml version="1.0" encoding="UTF-8"?&gt;
                              
                              &lt;beans xmlns="http://www.springframework.org/schema/beans"
                                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                     xsi:schemaLocation="http://www.springframework.org/schema/beans
                                     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
                              
                                &lt;!-- the application context definition for the springapp DispatcherServlet --&gt;
                              &lt;!-- &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;        
                                 &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"&gt;&lt;/property&gt;
                                 &lt;property name="prefix"&gt;                                                         
                                      &lt;value&gt;/WEB-INF/jsp/&lt;/value&gt;                                                 
                                  &lt;/property&gt;                                                                     
                                  &lt;property name="suffix"&gt;                                                         
                                      &lt;value&gt;.jsp&lt;/value&gt;                                                          
                                  &lt;/property&gt;                                                                      
                              &lt;/bean&gt; --&gt;                                                                             
                              
                              &lt;bean id="searchAccessFormValidator" class = "com.service.SearchAccessFormValidator" /&gt;
                              &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
                              	&lt;property name="mappings"&gt;
                              		&lt;props&gt;
                              			&lt;prop key="/SearchAccessServlet.do"&gt;searchAccessFormController&lt;/prop&gt;
                              			&lt;!-- &lt;prop key="/refresh.html"&gt;ppFormController&lt;/prop&gt; --&gt;
                              			&lt;!-- &lt;prop key="/PostProfileForm.html"&gt;ppFormController&lt;/prop&gt; --&gt;
                              		&lt;/props&gt;
                              	&lt;/property&gt;
                              &lt;/bean&gt;
                              
                               &lt;bean id="searchAccessFormController" class="com.web.SearchAccessFormController"&gt;
                                      &lt;property name="sessionForm" value="true"/&gt;
                                      &lt;property name="commandName" value="searchAccess"/&gt;
                                      &lt;property name="commandClass" value="com.service.SearchAccess"/&gt;
                                      &lt;!-- &lt;property name="validator"&gt;
                                          &lt;bean class="com.service.SearchAccessFormValidator"/&gt;
                                      &lt;/property&gt; --&gt;
                                      &lt;property name="validator" ref="searchAccessFormValidator"/&gt;
                                      &lt;!--&lt;property name="formView" value="index"/&gt;
                                      --&gt;&lt;property name="successView" value="index.jsp"/&gt;
                                  &lt;/bean&gt;
                              
                              
                              
                              &lt;/beans&gt;
                              Following is the code in SearchAccessFormController:

                              Code:
                               package com.web;
                              
                              import java.io.IOException;
                              
                              import javax.servlet.ServletException;
                              import javax.servlet.http.HttpServletRequest;
                              import javax.servlet.http.HttpServletResponse;
                              
                              import org.apache.commons.logging.Log;
                              import org.apache.commons.logging.LogFactory;
                              import org.springframework.web.servlet.ModelAndView;
                              import org.springframework.web.servlet.mvc.SimpleFormController;
                              import org.springframework.web.servlet.view.RedirectView;
                              
                              import com.service.SearchAccess;
                              
                              public class SearchAccessFormController extends SimpleFormController {
                              	private static final Log LOGGER = LogFactory
                              			.getLog(SearchAccessFormController.class);
                              	
                              	private String name;
                              	private Object commandName = "searchAccess";
                              	public String getname() {
                              		return name;
                              	}
                              
                              	public void setname(String name) {
                              		this.name = name;
                              	}
                              
                              	public ModelAndView handleRequest(final HttpServletRequest request,
                              			final HttpServletResponse response) throws ServletException,
                              			IOException {
                              		LOGGER.info("Returning hello view");
                              		return new ModelAndView("hello");
                              
                              	}
                              
                              	public ModelAndView onSubmit(Object command) throws ServletException {
                              		//System.out.println(((SearchAccess) command).getname());
                              		
                              		System.out.println("Hi onSubmit");
                              		//return new ModelAndView(new RedirectView(getSuccessView()));
                              		return new ModelAndView();
                              	}
                              
                              	protected Object formBackingObject(HttpServletRequest request)
                              			throws ServletException {
                              		System.out.println("Hi formBackingObject");
                              		return "Hello";
                              	}
                              
                              	
                              }
                              Following is the code in SearchAccess.java:

                              Code:
                                package com.service;
                              
                              import java.io.Serializable;
                              import org.apache.commons.logging.Log;
                              import org.apache.commons.logging.LogFactory;
                              /**
                               * @author corp
                               * 
                               */
                              public class SearchAccess implements Serializable {
                              	private String name;
                              	public String getname() {
                              		return name;
                              	}
                              	public void setname(String name) {
                              		this.name = name;
                              	}
                              }
                              I checked BindStatus.java in Spring code, but unable to find why target is null. The exception above is in index.jsp...Please help

                              Comment

                              Working...
                              X