开发者

Spring custom error message

开发者 https://www.devze.com 2022-12-30 00:43 出处:网络
I want to set a custom error message via @Controller, there is something like Struts saveMessages(...) in spring?

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

for example:

ActionErrors actionErrors开发者_C百科 = new ActionErrors();
actionErrors.add("error", new ActionMessage("error.missing.key",     
messageResources.getMessage("label.username"),  
messageResources.getMessage("label.password")));
saveErrors(request, actionErrors);


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号