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

📄 package-summary.html

📁 struts api,学习使用struts必备的文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
      <pre>
&lt;%@ taglib uri=&quot;/WEB-INF/struts-tiles.tld&quot; prefix=&quot;tiles&quot; %&gt;
&lt;HTML&gt;
  &lt;HEAD&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;%=request.getContextPath()%&gt;/layouts/stylesheet.css&quot; 
                  type=&quot;text/css&quot;/&gt;
    &lt;title&gt;&lt;tiles:getAsString name=&quot;title&quot;/&gt;&lt;/title&gt;
  &lt;/HEAD&gt;
&lt;body&gt;
&lt;table border=&quot;0&quot; width=&quot;100%&quot; cellspacing=&quot;5&quot;&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot;&gt;&lt;tiles:insert attribute=&quot;header&quot; /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td width=&quot;140&quot; valign=&quot;top&quot;&gt;
    &lt;tiles:insert attribute='menu' /&gt;
  &lt;/td&gt;
  &lt;td valign=&quot;top&quot;  align=&quot;left&quot;&gt;
    &lt;tiles:insert attribute='body' /&gt;
  &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot;&gt;
    &lt;tiles:insert attribute=&quot;footer&quot; /&gt;
  &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
      <p>The layout is declared in a JSP page (ex: /layouts/classicLayout.jsp). 
        It can be used in conjunction with the tag described in &quot;<a href="#doc.InsertPageWithAttributes">Insert
        a page passing some attributes</a>&quot;. </p>
</div>
</div>
<div class="section">
<h2>Definitions</h2>
    <p>A definition associates a logical name with the URL of a Tiles to be inserted 
      and some attribute values. A definition doesn't insert the Tiles. This is 
      done later using the definition name. A definition name can be inserted 
      as often as you want in your site, making it easy to reuse a Tiles. </p>
    <p>A definition can extend another definition and overload some attributes 
      or add new ones. This makes easy factorization of definitions differing 
      by some attributes. For example, you can define a master definition declaring 
      the main header, menu, footer, and a default title. Then let each of your 
      page definitions extend this master definition and overload the title and 
      the body.</p>
    <p>Definitions can be declared in a JSP page, or in one or more centralized 
      files. To enable the definitions from centralized files, you need to initialize 
      the &quot;definitions factory&amp;&amp;quot; which will parse the definitions from the files
      and provide them to the Tiles framework.</p>
<div class="subsection1">
<h3>Enabling Definition Factory</h3>
<p>To enable Tiles definitions described in one or more files, you need to write these files and to initialize the definition factory. </p>
      <p>Initialization is different depending on the Struts version you use, 
        or if you do not use Struts at all.</p>
<div class="subsection2">
<h4>Struts1.1</h4>
        <p>Use the Tiles plug-in to enable Tiles definitions. This plug-in creates 
          the definition factory and passese it a configuration object populated 
          with parameters. Parameters can be specified in the web.xml file or 
          as plug-in parameters. The plug-in first reads parameters from web.xml, 
          and then overloads them with the ones found in the plug-in. All parameters 
          are optional and can be omitted. The plug-in should be declared in each 
          struts-config file:</p>
<pre>
  &lt;plug-in className=&amp;&amp;quot;org.apache.struts.tiles.TilesPlugin&amp;&amp;quot; &gt;
    &lt;set-property property=&amp;&amp;quot;definitions-config&amp;&amp;quot; 
	                 value=&amp;&amp;quot;/WEB-INF/tiles-defs.xml,
                            /WEB-INF/tiles-tests-defs.xml,/WEB-INF/tiles-tutorial-defs.xml,
                            /WEB-INF/tiles-examples-defs.xml&amp;&amp;quot; /&gt;
    &lt;set-property property=&amp;&amp;quot;moduleAware&amp;&amp;quot; value=&amp;&amp;quot;true&amp;&amp;quot; /&gt;
    &lt;set-property property=&amp;&amp;quot;definitions-parser-validate&amp;&amp;quot; value=&amp;&amp;quot;true&amp;&amp;quot; /&gt;
  &lt;/plug-in&gt;
</pre>
<ul>
<li>definitions-config: (optional) <ul>
<li>Specify configuration file names. There can be several comma separated file names (default: ?? )</li>
</ul>
</li>
          <li>definitions-parser-validate: (optional)
<ul>
              <li>Specify if XML parser should validate the Tiles configuration 
                file 
                <ul>
                  <li>true : validate. DTD should be specified in file header (default)</li>
<li>false : no validation	  </li>

</ul>
</li>
</ul>
</li>

          <li>moduleAware: (optional)
           <ul>
              <li>Specify if the Tiles definition factory is module aware. If true (default), 
			there will be one factory for each Struts module. 
			If false, there will be one common factory for all module. In this later case, 
			it is still needed to declare one plugin per module. The factory will be 
			initialized with parameters found in the first initialized plugin (generally the
			one associated with the default module). 
            <ul>
             <li>true : Tiles framework is module aware </li>
             <li>false :Tiles framework has one single factoy shared among modules (default)</li>
            </ul>
           </li>
</ul>
</li>

<li>tilesUtilImplClassname: (optional - for advanced user)
 <ul>
    <li>Specify The classname of the TilesUtil implementation to use. The specified class should
	be a subclass of TilesUtilStrutsImpl. This option disable the moduleAware option.
	<br>Specifying &amp;&amp;quot;TilesUtilStrutsImpl&amp;&amp;quot; is equivalent to moduleAware = false.</br>
	<br>Specifying &amp;&amp;quot;TilesUtilStrutsModuleImpl&amp;&amp;quot; is equivalent to moduleAware = true.</br>
	This option is taken into account only once, when it is first encountered. To avoid problems,
	it is advice to specify the same values in all TilesPlugin declaration.
    </li>
 </ul>
</li>

</ul>
        <p>The TilesPlugin class creates one definition factory for each struts module.
		</p>
		<p>
		If the flag moduleAware is false, only one shared factory is created for all modules. 
		In this later case, the factory is initialized with parameters found in the first plugin.
		The plugins should be declared in all modules, and the moduleAware flag should be 
		the same for the entire application.</p> 
		<p>
          Paths found in Tiles definitions are relative to the main context.</p>
        <p>You don't need to specify a TilesRequestProcessor, this is automatically 
          done by the plug-in. If, however, you want to specify your own RequestProcessor, 
          it should extend the TilesRequestProcessor. The plug-in checks this 
          constraint.</p>
</div>
<div class="subsection2">
<h4>Struts1.0.x</h4>
<p>You need to use a special servlet extending the Struts servlet. This is specified in the web.xml file of your application:</p>
        <pre>
  &lt;servlet&gt;
    &lt;servlet-name&gt;action&lt;/servlet-name&gt;
	&lt;servlet-class&gt;org.apache.struts.tiles.ActionComponentServlet&lt;/servlet-class&gt;   
        &lt;!-- Tiles Servlet parameter 
		  Specify configuration file names. There can be several comma 
		  separated file names
		--&gt; 	
	&lt;init-param&gt;
      &lt;param-name&gt;definitions-config&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/tiles-defs.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
        &lt;!-- Tiles Servlet parameter 
		Specify if XML parser should validate the Tiles configuration file(s).
		true : validate. DTD should be specified in file header.
		false : no validation
		--&gt; 	
    &lt;init-param&gt;
      &lt;param-name&gt;definitions-parser-validate&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/init-param&gt;
     ...
  &lt;/servlet&gt;
</pre>
</div>
<div class="subsection2">
<h4>Without Struts</h4>
<p>Tiles can be used without Struts. To initialize the definition factory, you can use the provided servlet. Declare it in the web.xml file of your application:</p>
<pre>
  &lt;servlet&gt;
    &lt;servlet-name&gt;action&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.apache.struts.tiles.TilesServlet&lt;/servlet-class&gt;


	&lt;init-param&gt;
      &lt;param-name&gt;definitions-config&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/tiles-defs.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;definitions-parser-validate&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/init-param&gt;
   ...
</pre>
<p>The parameters are the same as for Struts1.1 or 1.0.</p>
</div>
</div>
<div class="subsection1">
<h3>Definition File Syntax</h3>
<p>The definition file syntax can be found in the 
<a href="http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">tiles-config_1_1.dtd file</a>. 
</p>
<p>Following is a simple example:</p>
      <pre>
&lt;!DOCTYPE tiles-definitions PUBLIC
       &amp;&amp;quot;-//Apache Software Foundation//DTD Tiles Configuration//EN&amp;&amp;quot;
       &amp;&amp;quot;http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd&amp;&amp;quot;&gt;

&lt;!-- Definitions for Tiles documentation   --&gt;
&lt;tiles-definitions&gt;

  &lt;!-- ========================================================== --&gt;
  &lt;!-- Master definition                                          --&gt;
  &lt;!-- ========================================================== --&gt;
  &lt;!-- Main page layout used as a root for other page definitions --&gt;

  &lt;definition name=&amp;&amp;quot;site.mainLayout&amp;&amp;quot; path=&amp;&amp;quot;/layouts/classicLayout.jsp&amp;&amp;quot;&gt;
	  &lt;put name=&amp;&amp;quot;title&amp;&amp;quot;  value=&amp;&amp;quot;Tiles Blank Site&amp;&amp;quot; /&gt;
	  &lt;put name=&amp;&amp;quot;header&amp;&amp;quot; value=&amp;&amp;quot;/tiles/common/header.jsp&amp;&amp;quot; /&gt;
	  &lt;put name=&amp;&amp;quot;menu&amp;&amp;quot;   value=&amp;&amp;quot;site.menu.bar&amp;&amp;quot; /&gt;
	  &lt;put name=&amp;&amp;quot;footer&amp;&amp;quot; value=&amp;&amp;quot;/tiles/common/footer.jsp&amp;&amp;quot; /&gt;
	  &lt;put name=&amp;&amp;quot;body&amp;&amp;quot;   value=&amp;&amp;quot;/tiles/body.jsp&amp;&amp;quot; /&gt;
  &lt;/definition&gt;

  &lt;!-- ========================================================== --&gt;
  &lt;!-- Index page definition                                      --&gt;
  &lt;!-- ========================================================== --&gt;
    &lt;!-- This definition inherits from the main definition.
	  It overloads the page title and the body used.
	  Use the same mechanism to define new pages sharing common 
	  properties (here header, menu, footer, layout)
	--&gt;

  &lt;definition name=&amp;&amp;quot;site.index.page&amp;&amp;quot; extends=&amp;&amp;quot;site.mainLayout&amp;&amp;quot; &gt;
	  &lt;put name=&amp;&amp;quot;title&amp;&amp;quot;  value=&amp;&amp;quot;Tiles Blank Site Index&amp;&amp;quot; /&gt;
	  &lt;put name=&amp;&amp;quot;body&amp;&amp;quot;   value=&amp;&amp;quot;/tiles/body.jsp&amp;&amp;quot; /&gt;
  &lt;/definition&gt;

&lt;/tiles-definition&gt;
</pre>
</div>
<div class="subsection1">
<h3>Debugging</h3>
<p>To debug a page made of Tiles, you can use following advices:</p>
<ul>
  <li>Check each Tiles separatly. Try to access nested Tiles directly to test 
  if thes work properly.</li>
  <li>Enable Tiles logging. See the commons-logging package help.</li>
</ul>
</div>
</div>
</div>
<P>
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/struts/taglib/tiles/util/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/struts/tiles/actions/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="package-summary.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>
Copyright 

⌨️ 快捷键说明

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