Spring's SimpleFormController problem

Discussion in 'Java' started by Pawel, Jan 22, 2008.

  1. Pawel

    Pawel Guest

    Hi,

    I have a strange problem with my Spring 2.5 and Tomcat 5.5
    application.

    I have a form which looks like this:


    <form:form method="post" commandName="loginCommand">
    <form:errors path="*" cssClass="errorBox" />
    <div id="login" class="lightBorder label">
    <div id="header" class="lightBorder">Login</div>
    user <form:input path="user"/> <form:errors path="user"/>
    password <form:password path="password"/> <form:errors
    path="password"/>

    <div id="submit"><input type="Submit" name="submit" class="submit"
    value=""></div>
    </div>
    </form:form>



    My controller of this form looks like this:

    public class LoginFormController extends SimpleFormController {
    private Logger log = Logger.getLogger(LoginFormController.class);

    public LoginFormController() {
    log.debug("Constructor");
    setCommandName("loginCommand");
    setCommandClass(LoginCommand.class);
    }

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

    My command class looks like this:

    public class LoginCommand {
    private String user;
    private String password;

    public String getUser() {
    return user;
    }
    public void setUser(String user) {
    this.user = user;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }
    }


    My dispatcher-servlet.xml's appropriate fragment looks like this:

    ....
    <bean id="loginFormController"
    class="org.dyndns.orzekanie.controller.LoginFormController">
    <property name="successView" value="/navigation/logon"/>
    <property name="formView" value="/authexclude/index"/>
    <property name="validator" ref="loginValidator"/>
    </bean>
    ....

    <bean id="urlMapping"
    class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
    <value>
    /jsp/authexclude/index.html=loginFormController
    </value>
    </property>
    <property name="order" value="0"/>
    </bean>
    .....





    When I'm trying to run my application and display my form I get:

    2008-01-22 16:59:44,578 610 DEBUG
    [org.dyndns.orzekanie.controller.LoginFormController] (main:)
    Constructor
    2008-01-22 16:59:44,703 735 INFO
    [org.springframework.web.servlet.DispatcherServlet] (main:)
    FrameworkServlet 'dispatcher': initializatio
    n completed in 203 ms
    2008-01-22 17:00:33,843 49875 ERROR
    [org.springframework.web.servlet.tags.form.InputTag] (http-8080-
    Processor24:) Neither BindingResult nor
    plain target object for bean name 'loginCommand' available as request
    attribute
    java.lang.IllegalStateException: Neither BindingResult nor plain
    target object for bean name 'loginCommand' available as request
    attribute
    at
    org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:
    142)
    at
    org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:
    161)
    at
    org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:
    18
    1)
    at
    org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:
    147)
    at
    org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:
    134
    )
    at
    org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.
    java:123)
    ........



    Everything looks allright for me - I find this exception very strange.
    Could someone give me some advice?
    Thanks,
    Pawel
     
    Pawel, Jan 22, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deep Silent Ocean

    Spring Framework Example

    Deep Silent Ocean, Mar 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,004
    Deep Silent Ocean
    Mar 15, 2006
  2. James Yong
    Replies:
    2
    Views:
    423
    Roedy Green
    Oct 3, 2005
  3. Nettar
    Replies:
    2
    Views:
    552
    Nettar
    Nov 25, 2006
  4. rmn190
    Replies:
    2
    Views:
    2,475
    Arne Vajhøj
    Jan 10, 2008
  5. Goldfish
    Replies:
    1
    Views:
    834
    Goldfish
    Nov 6, 2008
Loading...

Share This Page