目录

<x:out>

《x:out》标记显示XPath表达式的结果。 它的功能与《%= %》 JSP语法相同。

属性 (Attribute)

《x:out》标记具有以下属性 -

属性 描述 需要 默认
select 要计算为字符串的XPath表达式,通常使用XPath变量 YesNone
escapeXml 如果标记应该转义特殊的XML字符,则为True Notrue

例子 (Example)

让我们举一个例子,它将涵盖标签(a) 《x:out》 ,(b) 《x:parse》

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %>
<html>
   <head>
      <title>JSTL x:out Tags</title>
   </head>
   <body>
      <h3>Books Info:</h3>
      <c:set var = "xmltext">
         <books>
            <book>
               <name>Padam History</name>
               <author>ZARA</author>
               <price>100</price>
            </book>
            <book>
               <name>Great Mistry</name>
               <author>NUHA</author>
               <price>2000</price>
            </book>
         </books>
      </c:set>
      <x:parse xml = "${xmltext}" var = "output"/>
      <b>The title of the first book is</b>: 
      <x:out select = "$output/books/book[1]/name" />
      <br>
      <b>The price of the second book</b>: 
      <x:out select = "$output/books/book[2]/price" />
   </body>
</html>

上面的代码将产生以下结果 -

<h3>Books Info:</h3>
<b class="notranslate">The title of the first book is</b>: Padam History
<b class="notranslate">The price of the second book</b>: 2000
↑回到顶部↑
WIKI教程 @2018