Package org.apache.struts2.components
Class Compress
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.Compress
Used to compress HTML output. Just wrap a given section with the tag.
Security considerations:
- Body content is truncated in log messages to prevent sensitive data exposure
- Maximum size limit prevents DoS attacks via large inputs (configurable via struts.tag.compress.maxSize)
- Regex operations include safeguards against ReDoS attacks
Configurable attributes are:
- force (true/false) - always compress output, this can be useful in DevMode as devMode disables compression
Examples
<s:compress>
<s:form action="submit">
<s:text name="name" />
...
</s:form>
</s:compress>
Uses conditional compression depending on action
<s:compress force="shouldCompress">
<s:form action="submit">
<s:text name="name" />
...
</s:form>
</s:compress>
"shouldCompress" is a field with getter define on action used in expression evaluation- Since:
- 7.2.0
-
Field Summary
Fields inherited from class org.apache.struts2.components.Component
actionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCallback for the end tag of this component.voidsetCompressionEnabled(String compressionEnabled) voidvoidsetLogMaxLength(String logMaxLength) voidsetMaxSize(String maxSize) booleanusesBody()Overwrite to set if body should be used.Methods inherited from class org.apache.struts2.components.Component
addAllAttributes, addParameter, clearStandardAttributesMap, completeExpression, copyAttributes, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpression, toString
-
Constructor Details
-
Compress
-
-
Method Details
-
setCompressionEnabled
-
setMaxSize
-
setLogMaxLength
-
end
Description copied from class:ComponentCallback for the end tag of this component. Should the body be evaluated again?
NOTE: will pop component stack. -
usesBody
public boolean usesBody()Description copied from class:ComponentOverwrite to set if body should be used. -
setForce
-