春自定义错误消息(Spring custom error message)

2019-10-21 14:30发布

我想通过设置自定义错误消息@Controller ,也有一些是像Struts saveMessages(...)的春天?

例如:

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

Answer 1:

是的,看看验证器,验证对象等: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validator



文章来源: Spring custom error message