Latest web development tutorials

<C: out> tag

JSP Standard Tag Library JSP Standard Tag Library

<C: out> tag is used to display the results of an expression, and <% =%> role similar to the difference between them is that <c: out> "." Tags can be accessed directly through the operator properties.

For example, if you want to visit customer.address.street, just write: <c: out value = "customer.address.street">.

<C: out> tag will automatically ignore the XML markup characters, so they will not be treated as a tag.


Syntax

<c:out value="<string>" default="<string>" escapeXml="<true|false>"/>

Attributes

<C: out> tag has the following attributes:

Attributes description If necessary Defaults
value Content to be output Yes no
default The default value of the output no Subject contents
escapeXml Whether to ignore the 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>
<html>
    <head>
        <title>&lt;c:out&gt;实例</title>
    </head>
    <body>
        <h1>&lt;c:out&gt; 实例</h1>
			<c:out value="&lt要显示的数据对象(未使用转义字符)&gt" escapeXml="true" default="默认值"></c:out><br/>
  			<c:out value="&lt要显示的数据对象(使用转义字符)&gt" escapeXml="false" default="默认值"></c:out><br/>
		<c:out value="${null}" escapeXml="false">使用的表达式结果为null,则输出该默认值</c:out><br/>
    </body>
</body>
</html>

Results are as follows:

<c:out> 实例

&lt要显示的数据对象(未使用转义字符)&gt
<要显示的数据对象(使用转义字符)>
使用的表达式结果为null,则输出该默认值

JSP Standard Tag Library JSP Standard Tag Library