Search code examples
javajspvalidationstruts2interceptor

Error messages doesn't show up in my JSP


Hi i have a problem in my app, my jsp doesn't show error messages.

i don't realy understand this code in my jsp :

<s:if test="hasActionMessages()">
   <div class="message">
      <s:actionmessage/>
   </div>
</s:if>

<s:if test="hasFieldErrors()">
   <div class="errors">
      <s:fielderror />
   </div>
</s:if>

i don't understand hasActionMessages() & hasFieldErrors() are they defined some where?


Solution

  • Errors and messages are used in validation via validation interceptor. The code above checks if there action messages or field errors on the value stack.

    The action should implement WalidationAware to get these methods hasActionMessages() and hasFieldErrors() available to the OGNL. You don't need to implement it if your action extends ActionSupport. There's already implemented these methods.