开发者

Adding global error on any field error in struts2

I am using Struts2 and a bunch of Validation with Annotations. How do I add a global error mes开发者_运维百科sage as well on top of field validation errors. Thanks, Fedor


An action has a collection called fieldErrors as well as a collection called actionErrors. I can't remember if its in the base class ActionSupport, but you can try the method addActionError(String message) and then it will be available along with any field errors.

Keep in mind that action errors are separate from field errors and kept in a different collection. The field errors are in a Map so the UI can match up the error with the field name where as the action errors are just a List I think.

I think there are two UI tags <s:fielderrors/> and <s:actionerrors/> but you should check the Struts2 tag reference.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜