Put
<s:actionerrors />
and
<s:actionmessages />
in your jsp
And, for a better graphic result, use a specific div container (one red, one green, for example), and before checking to see if you have any messages or errors (to print the div if it is not empty):
<s:if test="hasActionErrors()">
<div class="feedError">
<s:actionerrors />
</div>
</s:if>
<s:if test="hasActionMessages()">
<div class="feedOk">
<s:actionmessages />
</div>
</s:if>
and in CSS
.feedError{
width: 100%;
border: 10px solid red;
}
.feedOk{
width: 100%;
border: 10px solid green;
}
EDIT: , , " " HTML.
ajax- , JSon, , .
JSP;
HTML, Scriptlets , JSP.
FreeMarker, .
JSP - (untested) .ftl:
<#if (actionErrors?size>0)>
<div class="feedError">
<@s.actionerror />
</div>
</#if>
<#if (actionMessages?size>0)>
<div class="feedOk">
<@s.actionmessage />
</div>
</#if>
Velocity ( , ):
#if( $actionErrors.size() > 0 )
<div class="feedError">
#foreach( $msg in $actionErrors )
[$msg]<br />
#end
</div>
#end
#if( $actionMessages.size() > 0 )
<div class="feedOk">
#foreach( $msg in $actionMessages )
[$msg]<br />
#end
</div>
#end
. JSP , web.xml,
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>
JSP Struts2 - , , imho.