views:

234

answers:

1

I want to set a custom error message via @Controller, there is something like Struts saveMessages(...) in spring?

for example:

ActionErrors actionErrors = new ActionErrors();
actionErrors.add("error", new ActionMessage("error.missing.key",     
messageResources.getMessage("label.username"),  
messageResources.getMessage("label.password")));
saveErrors(request, actionErrors);
+1  A: 

Yes, look at validation, Validators objects and so on: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validator

Bartek Jablonski