Announcement Announcement Module
Collapse
No announcement yet.
Problem with SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with SimpleFormController

    Hi,
    I am using a controller with SimpleFormController as base class and I am getting an exception the first time I go to the page :
    javax.servlet.ServletException: Could not find Errors instance for bean [MyBean] in request: add the Errors model to your ModelAndView via errors.getModel()
    here is the method I implemented in my controller :
    Code:
        protected void doSubmitAction(Object command) throws Exception {
            log.info(command);
        }
    and here is the jsp view :
    Code:
          	<spring&#58;bind path="MyBean.text">
            	<input type="text" name="$&#123;status.expression&#125;">
           	</spring&#58;bind>
    Any idea ?

  • #2
    Try this if MyBean is the command object:

    Code:
    <spring&#58;bind path="command.text">
      <input type="text" name="$&#123;status.expression&#125;">
    </spring&#58;bind>
    or this if your command object has a "myBean" property (e.g. getMyBean):

    Code:
    <spring&#58;bind path="command.myBean.text">
      <input type="text" name="$&#123;status.expression&#125;">
    </spring&#58;bind>
    I am assuming that you have not changed the default commandName of your controller. If you have changed it, substitute "command" in the above examples with your custom commandName.

    Also note that if you want the text box to be initialized with the value of the "text" property you will need to do this:

    Code:
    <input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;">

    Comment


    • #3
      thanks a lot. It worked !

      Comment

      Working...
      X