-
Jul 16th, 2007, 09:29 AM
#1
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.
-
Jul 16th, 2007, 10:23 AM
#2
I've blogged about this here - http://reverttoconsole.com/archives/118
Hope it helps
-
Jul 16th, 2007, 08:39 PM
#3
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
-
Forum Rules