Struts2 configuration error message

I am using struts2 in my application and am trying to execute the diplay error message using "s: actionerror /". It is aperture, but the dot (.) Also appears with an error message that looks ugly and displays as a list.

Is there a way to cuatomize error messages in struts2.

Thanks in advance.

+3
source share
5 answers

Brian Jarger's answer is the most complete solution. On the other hand, the simplest solution is to simply use CSS and change the li element.

JSP:

<s:if test="hasActionErrors()">
   <div class="errors">
      <s:actionErrors/>
   </div>
</s:if>

CSS

li .errors { list-style: none; }
+4
source

Another solution is to override the default actionError output template.

struts2. template.simple/actionerror.ftl, . s: actionerror , /template/simple, .

freemarker, struts2. .

+1

, kozmic :

JSP:

<s:if test="hasActionErrors()">
   <div class="errors">
      <s:actionErrors/>
   </div>
</s:if>

CSS

div .errors li { list-style: none; }

CSS-.

+1

, .

<table align="center" width="70%" class="stats">
                        <tr>
                        <s:if test="hasActionErrors()">
                            <s:iterator value="actionErrors">
                                <tr>
                                    <td class="error">
                                        <img alt="error message" src="./images/cross.gif" width="10" height="10"/>&nbsp;<s:property escape="false" />
                                    </td>
                                </tr>
                            </s:iterator>
               </s:if>

.

0

I know this is an old question, but I want to share my simple solution. It simply prints out every error message without additional html markup generated. Then you can wrap <s:property value="%{error}"/>in some custom html if you want.

<s:if test="hasActionErrors()">
    <s:iterator var="error" value="%{actionErrors}">
        <s:property value="%{error}"/>
    </s:iterator>
</s:if>
0
source

Source: https://habr.com/ru/post/1712532/


All Articles