Results 1 to 3 of 3

Thread: How to display a global error in jsp?

  1. #1
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    2

    Default How to display a global error in jsp?

    Hi guys,

    I'm a newbie just from Struts to Spring2.

    In my controller class, I have the following code adding a global error:

    try {
    user = userService.authenticate(form.getLoggingName(), form.getPassword());
    } catch (UserAuthenticationException e) {
    errors.reject(e.getMessage());
    form.setPassword(null);
    request.setAttribute(getCommandName(), form);
    return new ModelAndView(getFormView());
    }

    The question is how to display the error in jsp page?

    I have tried:

    1) <form:errors />
    2) <form:errors path="commandName" />

    but no luck.

    Can anyone give me a hint on this??

    Any input is welcome. thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    Boston, US
    Posts
    167

    Default

    I've blogged about this here - http://reverttoconsole.com/archives/118
    Hope it helps

  3. #3
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    2

    Default

    Thanks infinity2heaven.

    However,that's not what I meant.

    The 'global error' I was referring is:

    http://static.springframework.org/sp...va.lang.String)

    org.springframework.validation.BindException

    public void reject(String errorCode)

    Description copied from interface: Errors
    Register a global error for the entire target object, using the given error description.

    Specified by:
    reject in interface Errors

    Parameters:
    errorCode - error code, interpretable as a message key

    It says the global error is for the entire target object. In my understanding, it's the form object.

    My question is how to output the error for the target object in a jsp page.

    Please help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •