Pages Navigation Menu

Coding is much easier than you think

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

Posted by on Jan 4, 2014 in Struts 2 Tutorial, Struts-2 | 1 comment

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.

Read More