Class TagWriter
java.lang.Object
org.springframework.web.servlet.tags.form.TagWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendValue(String value) Close the current opening tag (if necessary) and appends the supplied value as inner text.voidendTag()Close the current tag.voidendTag(boolean enforceClosingTag) Close the current tag, allowing to enforce a full closing tag.voidIndicate that the currently open tag should be closed and marked as a block level element.voidStart a new tag with the supplied name.voidwriteAttribute(String attributeName) Variant ofwriteAttribute(String, String)for writing empty HTML attributes without a value such asrequired.voidwriteAttribute(String attributeName, String attributeValue) Write an HTML attribute with the specified name and value.voidwriteOptionalAttributeValue(String attributeName, @Nullable String attributeValue) Write an HTML attribute if the supplied value is notnullor zero length.
-
Constructor Details
-
TagWriter
-
TagWriter
-
-
Method Details
-
startTag
Start a new tag with the supplied name. Leaves the tag open so that attributes, inner text or nested tags can be written into it.- Throws:
jakarta.servlet.jsp.JspException- See Also:
-
writeAttribute
public void writeAttribute(String attributeName, String attributeValue) throws jakarta.servlet.jsp.JspException Write an HTML attribute with the specified name and value.Be sure to write all attributes before writing any inner text or nested tags.
- Throws:
IllegalStateException- if the opening tag is closedjakarta.servlet.jsp.JspException
-
writeAttribute
Variant ofwriteAttribute(String, String)for writing empty HTML attributes without a value such asrequired.- Throws:
jakarta.servlet.jsp.JspException- Since:
- 5.3.14
-
writeOptionalAttributeValue
-
appendValue
Close the current opening tag (if necessary) and appends the supplied value as inner text.- Throws:
IllegalStateException- if no tag is openjakarta.servlet.jsp.JspException
-
forceBlock
public void forceBlock() throws jakarta.servlet.jsp.JspExceptionIndicate that the currently open tag should be closed and marked as a block level element.Useful when you plan to write additional content in the body outside the context of the current
TagWriter.- Throws:
jakarta.servlet.jsp.JspException
-
endTag
public void endTag() throws jakarta.servlet.jsp.JspExceptionClose the current tag.Correctly writes an empty tag if no inner text or nested tags have been written.
- Throws:
jakarta.servlet.jsp.JspException
-
endTag
public void endTag(boolean enforceClosingTag) throws jakarta.servlet.jsp.JspException Close the current tag, allowing to enforce a full closing tag.Correctly writes an empty tag if no inner text or nested tags have been written.
- Parameters:
enforceClosingTag- whether a full closing tag should be rendered in any case, even in case of a non-block tag- Throws:
jakarta.servlet.jsp.JspException
-