2

Struts - Alternative of <html:errors /> to display error messages in Jsp?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Amit
  • 33,847
  • 91
  • 226
  • 299

1 Answers1

6

By setting the attribute message="false" on the <html:messages /> tag, it gets all errors stored on ActionMessages list if saveErrors was called.

<logic:messagesPresent message="false">
                        <html:messages id="aMsg" message="false">
                            <logic:present name="aMsg">
                                <!-- Error -->
                                <div class="error">
                                    <bean:write name="aMsg" filter="false" />
                                </div>
                            </logic:present>
                        </html:messages>
                    </logic:messagesPresent>

The <html:messages id="aMsg" message="false"> display messages stored on saveErrors while <html:messages id="aMsg" message="true"> display messages stored on saveMessages. There is no more ActionErrors object, just ActionMessages. The 'saveErrors' and 'saveMessages' method seperates the errors and messages respectively.

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • Actually I wanted to use for displaying errors but I couldn't find struts-html.tld file that's why I moved to other alternative approaches... Could you please tell me the answer of the question at http://stackoverflow.com/questions/2388133/struts-in-which-jar-file-all-the-tld-files-located – Amit Mar 06 '10 at 18:33
  • 2
    has been removed on the newer versions of Struts. It hasn't been removed on the TLD's since Struts have long removed their TLD's from the Struts set. They just keeping it for backward compatibility purposes. Rather use JSTL has it's compatible to be used with Struts. – Buhake Sindi Mar 06 '10 at 22:09