How to custom print actionErrors / fieldErrors with Velocity on Struts2

struts2-merger2

Just a quick code snippet, that couldn’t find anywhere on the net as an example and my colleague Aggelos offered to me 🙂

#if( $actionErrors.size() > 0 )
#foreach( $msg in $actionErrors )
[$msg]<br />
#end
#end

Same for fieldErrors. Use them instead of the default #sactionerror , #sfielderror etc to produce custom html. If you only need css formatting, override your css as described in the comments on this webpage. Of course, you can always override the default freemarker template for errors on the struts jar file, to provide uniform handling of error formatting

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.