Formatting Issue in HTML messages from ResourceBundle using or in Struts2

后端 未结 1 2057
说谎
说谎 2021-01-29 01:26

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.<

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-29 01:53

    The and tags will encapsulate your actionerrors and actionmessages in

    • yourmessage
    .

    This will make your message starting with a circle dot (because it is inside an

  • ) and the other nested
  • with the circle outline (as defined by HTML for second-level
  • ).

    This:

    
    

    will generate:

    • 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

    To generate the output you want, you can write your own .ftl, or more easily avoid using the / tags, and do the loop by yourself:

    
        

    result:

    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

    You can do the loop for actionMessages, actionErrors and eventually fieldErrors and put them in a messages.jsp snippet, so you can use it in every page (without rewriting it every time) with something like:

    
    

0 讨论(0)
提交回复
热议问题