Pages Navigation Menu

Coding is much easier than you think

Changing default style of s:actionerror / s:actionmessage tag

default style
In struts 2 when you use <s:actionerror /> tag, it displays the errors with bullets, On viewing the page source of the jsp page, we can see that error message is displayed using

<li>error 1</li>
<li>error 2</li>

But suppose if our requirement is to display the error message without bullet in the action errors or action messages
** UPDATE: Struts 2 Complete tutorial now available here.
There are 2 ways to solve this problem
1. Customized the code in jsp, such that you can specify your own css for displaying the message

<s:if test="hasActionErrors()">
<s:iterator value="actionErrors">
<span class="msg"><s:property escape="false" />

2. Change the file in the “/template/simple/actionerror.ftl” and put it in the /web-directory/struts/simple if you are using simple theme

Recommended reading

Similar kind of approach is followed for <s:actionmessage /> tag.

About Mohaideen Jamil

Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • Ogirala ashok Reddy

    you are saying we need to change actionerror.ftl but the question is where to change and to what? your answer is kind of missing the main point which is “how to change the default style of actionerrors” .