<c:out> Tag
The <c:out> tag is used to display the result of an expression, similar to <%= %>, with the difference that the <c:out> tag can directly access properties via the "." operator.
For example, if you want to access customer.address.street, you only need to write: <c:out value="customer.address.street">.
The <c:out> tag automatically ignores XML markup characters, so they will not be treated as tags.
Syntax Format
<c:out value="<string>" default="<string>" escapeXml="<true|false>"/>
Attributes
The <c:out> tag has the following attributes:
| Attribute | Description | Required? | Default Value |
|---|---|---|---|
| value | Content to output | Yes | None |
| default | Default output value | no | Content in the body |
| escapeXml | Whether to ignore XML special characters | no | true |
Program Example
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:out 标签实例</title>
</head>
<body>
<h1><c:out> 实例</h1>
<c:out value="<要显示的数据对象(未使用转义字符)>" escapeXml="true" default="默认值"></c:out><br/>
<c:out value="<要显示的数据对象(使用转义字符)>" escapeXml="false" default="默认值"></c:out><br/>
<c:out value="${null}" escapeXml="false">使用的表达式结果为null,则输出该默认值</c:out><br/>
</body>
</html>
The running result is as follows:
<c:out> 实例 <要显示的数据对象(未使用转义字符)> <要显示的数据对象(使用转义字符)> 使用的表达式结果为null,则输出该默认值
Other Extensions
JSP Standard Tag Library