⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 struts-tiles.html

📁 struts api,学习使用struts必备的文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Tiles Tag Library</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Cedric Dumoulin" name="author" />
<link href="../struts.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="heading">
<a href="http://apache.org/">
<img id="asf_logo_wide" alt="The Apache Project" src="../images/asf_logo_wide.gif" />
</a>
<a href="http://struts.apache.org/">
<img id="struts-logo" alt="Struts Framework" src="../images/struts.gif" />
</a>
</div>
<!--end heading-->
<div id="content">
<div id="menu">

    
    
    <p>User Guide</p>
<ul>
      <li>
<a href="index.html">Table of Contents</a>
</li>
      <li>
<a href="preface.html">Preface</a>
</li>
      <li>
<a href="introduction.html">Introduction</a>
</li>
      <li>
<a href="building_model.html">Model Components</a>
</li>
      <li>
<a href="building_view.html">View Components</a>
</li>
      <li>
<a href="building_controller.html">Controller Components</a>
</li>
      <li>
<a href="configuration.html">Configuration</a>
</li>
      <li>
<a href="release-notes.html">Release Notes</a>
</li>
      <li>
<a href="installation.html">Installation</a>
</li>
    </ul>

    <p>Developer Guides</p>
<ul>
        <li>
<a href="dev_bean.html">Bean Tags</a>
</li>
        <li>
<a href="dev_html.html">HTML Tags</a>
</li>
        <li>
<a href="dev_logic.html">Logic Tags</a>
</li>
        <li>
<a href="dev_nested.html">Nested Tags</a>
</li>
        <li>
<a href="dev_tiles.html">Tiles Tags</a>
</li>
        <li>
<a href="dev_util.html">Utilities</a>
</li>
        <li>
<a href="dev_validator.html">Validator</a>
</li>
    </ul>

    <p>Quick Links</p>
<ul>
        <li>
<a href="../index.html">Welcome</a>
</li>
        <li>
<a href="index.html">User and Developer Guides *</a>
</li>
        <li>
<a href="../faqs/index.html">FAQs and HowTos</a>
</li>
    </ul>

</div>
<!--end menu-->
<div id="main">


<h2 id="top">Tiles Tag Library</h2>
<div class="indent">
    <p>This tag library provides tiles tags.</p>
    <p>Tiles were previously called Components. For historical reasons, names, pages, components and templates
    are used indifferently to design a tile. Also, a lot of tags and attribute names are
    left for backward compatibility.</p>
    <p>To know more about tags defined in this library, check the associated documentation:
    tiles-doc.</p>
  <table class="taglib-summary">
<thead>
<tr>
<th>Tag Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">
<a href="#insert">insert</a>
</td>
<td>
    Insert a tiles/component/template.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#definition">definition</a>
</td>
<td>
    Create a tile /component / template definition bean.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#put">put</a>
</td>
<td>
      Put an attribute into tile/component/template context.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#putList">putList</a>
</td>
<td>
      Declare a list that will be pass as attribute to tile.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#add">add</a>
</td>
<td>
       Add an element to the surrounding list.
       Equivalent to 'put', but for list element.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#get">get</a>
</td>
<td>
    Gets the content from request scope that was put there by a
    put tag.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#getAsString">getAsString</a>
</td>
<td>
      Render the value of the specified tile/component/template attribute to the current JspWriter
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#useAttribute">useAttribute</a>
</td>
<td>
      Use attribute value inside page.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#importAttribute">importAttribute</a>
</td>
<td>
      Import Tile's attribute in specified context.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#initComponentDefinitions">initComponentDefinitions</a>
</td>
<td>
      Initialize Tile/Component definitions factory.
    </td>
</tr>
</table>
</div>
<h3 id="insert">
<strong>insert</strong> - 
    Insert a tiles/component/template.
    </h3>
<div class="indent">
    <p>Insert a tiles/component/template with the possibility to pass parameters
    (called attribute).
    A tile can be seen as a procedure that can take parameters or attributes.
    <code>&lt;tiles:insert&gt;</code> allows to define these attributes and pass them to the inserted jsp page,
    called template.
    Attributes are defined using nested tag <code>&lt;tiles:put&gt;</code> or
    <code>&lt;tiles:putList&gt;</code>.
    </p>
    <p>
    You must specify one of this tag attribute :
    </p>
      <ul>
      <li>
<code>template</code>, for inserting a tiles/component/template page,</li>
      <li>
<code>component</code>, for inserting a tiles/component/template page, (same as template)</li>
      <li>
<code>page</code> for inserting a JSP page, (same as template)</li>
      <li>
<code>definition</code>, for inserting a definition from definitions factory</li>
      <li>
<code>attribute</code>, surrounding tiles's attribute name whose value is used.
        <br />If attribute is associated to 'direct' flag (see put), and flag is true, write
        attribute value (no insertion).
      </li>
      <li>
<code>name</code>, to let 'insert' determine the type of entities to insert. In this later
      case, search is done in this order : definitions, tiles/components/templates, pages.
      </li>
      </ul>
      <p>
      In fact, Page, component and template, are equivalent as a tile, component or template are jsp page.
      </p>
      <p>
<strong>Example : </strong>
</p>
        <pre>
<code>
          &lt;tiles:insert page="/basic/myLayout.jsp" flush="true"&gt;
            &lt;tiles:put name="title"  value="My first page" /&gt;
            &lt;tiles:put name="header" value="/common/header.jsp" /&gt;
            &lt;tiles:put name="footer" value="/common/footer.jsp" /&gt;
            &lt;tiles:put name="menu"   value="/basic/menu.jsp" /&gt;
            &lt;tiles:put name="body"   value="/basic/helloBody.jsp" /&gt;
          &lt;/tiles:insert&gt;</code>
</pre>
    <table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">template</td>
<td>
        <p>A string representing the URI of a tile or template (a JSP page).</p>
        <p>'page', 'component' and 'template' are synonyms : they have exactly the same behavior.</p>
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">component</td>
<td>
        <p>Path (relative or absolute to webapps) of the component to insert.</p>
        <p>'page', 'component' and 'template' are synonyms : they have exactly the same behavior.</p>
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">page</td>
<td>
        <p>Path (relative or absolute to webapps) of the page to insert.</p>
        <p>'page', 'component' and 'template' are synonyms : they have exactly the same behavior.</p>
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">definition</td>
<td>
        Name of the definition to insert. Definition are defined in a centralized file.
        For now, only definition from factory can be inserted with this attribute.
        To insert a definition defined with tag &lt;tiles:definition&gt;, use beanName="".
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">attribute</td>
<td>
        Name of an attribute in current tile/component context. Value of this attribute is passed to
        'name' (see attribute 'name').
      </td>
</tr>
<tr class="oddRow">
<td align="center">name</td>
<td>
        Name of an entity to insert. Search is done in this order : definition, attribute,
        [tile/component/template/page].
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">beanName</td>
<td>
      <p>Name of the bean used as value. Bean is retrieved from specified context, if any. Otherwise,
      method pageContext.findAttribute is used.
      If beanProperty is also specified, retrieve value from the corresponding bean property.</p>
      <p>If found bean (or property value) is instance of one of Attribute class (Direct,
      Instance, ...), insertion is done according to the class type. Otherwise, the toString method is
      called on the bean, and returned String is used as name to insert (see 'name' attribute).</p>
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">beanProperty</td>
<td>
      Bean property name. If specified, value is retrieve from this property. Support nested/indexed
      properties.
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">beanScope</td>
<td>
      Scope into which bean is searched. If not specified, method pageContext.findAttribute is used.
      Scope can be any JSP scope, 'component', or 'template'.
      In these two later cases, bean is search in tile/component/template context.
      </td>
</tr>
<tr class="oddRow">
<td align="center">flush</td>
<td>
        True or false. If true, current page out stream is flushed before insertion.
      </td>
</tr>
<tr class="evenRow">
<td align="center">ignore</td>
<td>
      If this attribute is set to true, and the attribute specified by the name
      does not exist, simply return without writing anything. The default value is false, which will
      cause a runtime exception to be thrown.
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">role</td>
<td>
      If the user is in the specified role, the tag is taken into account;
      otherwise, the tag is ignored (skipped).
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">controllerUrl</td>
<td>
      <p>Url of a controller called immediately before page is inserted.</p>
      <p>
      Url usually denote a Struts action. Controller (action) is used to prepare data
      to be render by inserted Tile.
      </p>
      <p>See also controlerClass. Only one of controllerUrl or controllerClass should be used.</p>
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">controllerClass</td>
<td>
      <p>Class type of a controller called immediately before page is inserted.</p>
      <p>Controller is used to prepare data to be render by inserted Tile.</p>
      <p>See also controlerUrl</p>
      <p>Class must implements or extends one of the following :</p>
      <ul>
        <li>org.apache.struts.tiles.Controller</li>
        <li>org.apache.struts.tiles.ControllerSupport</li>
        <li>org.apache.struts.action.Action (wrapper org.apache.struts.action.ActionController is used)</li>
      </ul>
      <p>
      See also controllerUrl. Only one of controllerUrl or controllerClass should be used.
      </p>
      
            [RT Expr]
          </td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="definition">
<strong>definition</strong> - 
    Create a tile /component / template definition bean.
    </h3>
<div class="indent">
    Create a tile/component/template definition as a bean.
    Newly created bean will be saved under specified "id", in the requested "scope".
    Definition tag has same syntax as <code>insert</code> tag.
    The new definition can extends a definition described in factory (XML file), and overload
    any previously defined parameters.
    <table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">id</td>
<td>
      Specifies the name under which the newly created definition bean will be saved.
      
            [Required]
          </td>
</tr>
<tr class="oddRow">
<td align="center">scope</td>
<td>
      Specifies the variable scope into which the newly defined bean will be created.
      If not specified, the bean will be created in page scope.
      </td>
</tr>
<tr class="evenRow">
<td align="center">template</td>
<td>
      A string representing the URI of a tile/component/template (a JSP page).
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">page</td>
<td>
      URL of the template / component to insert. Same as "template".
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">role</td>
<td>
      Role to check before inserting this definition. If role is not defined for current user,
      definition is not inserted. Checking is done at insert time, not during definition process.
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">extends</td>
<td>
      Name of a parent definition that is used to initialize this new definition.
      Parent definition is searched in definitions factory.
      
            [RT Expr]
          </td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="put">
<strong>put</strong> - 
      Put an attribute into tile/component/template context.
    </h3>
<div class="indent">
      Define an attribute to pass to tile/component/template.
      This tag can only be used inside 'insert' or 'definition' tag.
      Value (or content) is specified using attribute 'value' (or 'content'), or using the tag body.
      It is also possible to specify the type of the value :
      <ul>
      <li>string : Content is written directly.</li>
      <li>page | template : Content is included from specified URL. Name is used as an URL.</li>
      <li>definition : Content come from specified definition (from factory). Name is used as definition name.</li>
      </ul>
      If type is specified, it is taken into account by 'get' or 'insert' inside the inserted tile.
      <p>If 'type' attribute is not specified, content is 'untyped', unless it comes from a typed bean.</p>
      <p>Note that using 'direct="true"' is equivalent to 'type="string"'.</p>
    <table class="tag-attributes">
<thead>
<tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -