I have a properties file (resource bundle). I am trying to show errors in one of the jsp by loading them from properties file. I have an entry as below in my properties file.
errors.password.rules=<font color="red">The password you have entered does not meet password strength requirements. Please select a new password that conforms to the following standards:<UL><LI>Minimum length of 8 characters</LI> <LI>Maximum length of 18 characters</LI><LI>At least one upper-case character</LI> <LI>At least one lower-case character</LI><LI>At least one non-alphabetic character</LI> <LI>Does not contain 3 or more consecutive repeating characters (e.g. AAA)</LI> <LI>Does not contain the User ID</LI><LI>Does not contain common dictionary words more than 4 characters long</LI><LI>New Password should not be the same as previous password</LI></UL></font>
The above when loaded using struts 1 shows as below
The password you have entered does not meet password strength requirements. Please select a new password that conforms to the following standards:
- Minimum length of 8 characters
- Maximum length of 18 characters
- At least one upper-case character
- At least one lower-case character
- At least one non-alphabetic character
- Does not contain 3 or more consecutive repeating characters (e.g. AAA)
- Does not contain the User ID
- Does not contain common dictionary words more than 4 characters long
- New Password should not be the same as previous password
The same when loaded with Struts 2 shows see attached file for output
• The password you have entered does not meet password strength requirements. Please select a new password that conforms to the following standards: o Minimum length of 8 characters o Maximum length of 18 characters o At least one upper-case character o At least one lower-case character o At least one non-alphabetic character o Does not contain 3 or more consecutive repeating characters (e.g. AAA) o Does not contain the User ID o Does not contain common dictionary words more than 4 characters long o New Password should not be the same as previous password
The above is displaying with the circled bullet, each in a next line. And for bullet is coming for first line
Please suggest what changes i have to do to my properties files to load the errors same as with struts 1.x.
The
<s:actionerror/>
and<s:actionmessage/>
tags will encapsulate youractionerrors
andactionmessages
in<ul><li><span>yourmessage</span></li></ul>
.This will make your message starting with a circle dot (because it is inside an
<li>
) and the other nested<li>
with the circle outline (as defined by HTML for second-level<li>
).This:
will generate:
To generate the output you want, you can write your own .ftl, or more easily avoid using the
<s:actionerror/>
/<s:actionmessage>
tags, and do the loop by yourself:result:
You can do the loop for
actionMessages
,actionErrors
and eventuallyfieldErrors
and put them in amessages.jsp
snippet, so you can use it in every page (without rewriting it every time) with something like: