Annotation Type MaxLength


@Documented @Inherited @Target(FIELD) @Retention(RUNTIME) public @interface MaxLength

Defines error message to display if a String form field (whether on a Struts Action or model of ModelDriven Struts Action) exceeds a maximum length.

By default, messages are added to the actionErrors list but this can be overridden by messageType:

Message Types
ERROR Message added to Action level error messages. Default.
FIELD Message added to field error messages using same name as field.
MESSAGE Message added to Action level info messages.
WARNING Message added to Action level warning messages.

Other parameters

Other Parameters
maxLength Maximum length of string. No default.
message If not empty string, text message to display. Used if messageKey is not set or finds no message.
messageKey If not empty string, message key to retrieve from Action's TextProvider. Uses message if no key provided or no message found.
shortCircuit If true and this validation fails, skips further validation. Defaults to false.
trim Whether to ignore whitespace from the beginning and end. Defaults to true.
  • Element Details

    • maxLength

      int maxLength
    • message

      String message
      Default:
      ""
    • messageKey

      String messageKey
      Default:
      ""
    • messageType

      Default:
      ERROR
    • shortCircuit

      boolean shortCircuit
      Default:
      false
    • trim

      boolean trim
      Default:
      true