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

📄 user-guide.html

📁 框架结构,适用一些初学者使用. 请先压缩再使用
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Struts Scripting User Guide - Apache Struts - Scripts BSF Scripting</title><style type="text/css" media="all">          @import url("./style/maven-base.css");                    @import url("./style/maven-theme.css");</style><link rel="stylesheet" href="./style/print.css" type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta></head><body class="composite"><div id="banner"><a href="http://www.apache.org/" id="organizationLogo"><img alt="The Apache Software Foundation" src="http://www.apache.org/images/asf-logo.gif"></img></a><a href="http://struts.apache.org/struts-scripting" id="projectLogo"><img alt="Struts Scripting" src="http://struts.apache.org/images/struts.gif"></img></a><div class="clear"><hr></hr></div></div><div id="breadcrumbs"><div class="xleft">Last published: 17 December 2005                <span class="separator">|</span>燚oc for  1.0.1                </div><div class="xright"></div><div class="clear"><hr></hr></div></div><div id="leftColumn"><div id="navcolumn"><div id="menuStruts_BSF_Scripting"><h5>Struts BSF Scripting</h5><ul><li class="none"><a href="index.html">Welcome</a></li><li class="none"><a href="index.html#features">Features</a></li><li class="none"><a href="index.html#documentation">Documentation</a></li><li class="none"><a href="user-guide.html">User Guide</a></li><li class="none"><a href="source-guide.html">Source Guide</a></li><li class="none"><a href="http://struts.apache.org/acquiring.html" class="externalLink" title="External Link">Download</a></li></ul></div><div id="menuQuick_Links"><h5>Quick Links</h5><ul><li class="none"><a href="../index.html">Apache Struts Home</a></li></ul></div><div id="menuProject_Documentation"><h5>Project Documentation</h5><ul><li class="none"><a href="index.html">About</a></li><li class="collapsed"><a href="project-info.html">Project Info</a></li><li class="collapsed"><a href="maven-reports.html">Project Reports</a></li><li class="none"><a href="http://maven.apache.org/development-process.html" class="externalLink" title="External Link">Development Process</a></li></ul></div><div id="legend"><h5>Legend</h5><ul><li class="externalLink">External Link</li><li class="newWindow">Opens in a new window</li></ul></div><a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy"><img alt="Built by Maven" src="./images/logos/maven-button-1.png"></img></a></div></div><div id="bodyColumn"><div class="contentBox"><div class="section"><a name="Struts_Scripting_User_Guide"></a><h2>Struts Scripting User Guide</h2>      <a name="overview"></a>      <p>The entire Struts Scripting project is only a few classes, since most of      the heavy lifting is done by the       <a href="http://jakarta.apache.org/bsf" class="externalLink" title="External Link">Bean Scripting Framework</a>       and the scripting engines themselves.  Therefore, there are only a few steps      you'll need to take in order to sucessfully install and use Struts Scripting.        </p>      <ul>        <li><a href="#installation">Installation</a></li>        <li><a href="#usage">Usage</a></li>      </ul>      <div class="subsection"><a name="Installation"></a><h3>Installation</h3>      <a name="installation"></a>         <p>After downloading the Struts Scripting distribution, copy the Struts         Scripting jar, <code>struts-scripting-1.0.1.jar</code>, to your application's         libraries directory.  When deployed, this directory will be <code>WEB-INF/lib</code>.         </p>         <p>Next, choose which scripting engine you want to use.  BSF ships with knowledge about         the following languages and script extensions:</p>         <table class="bodyTable">            <caption>              <strong>BSF-supported languages and extentions</strong>            </caption>            <thead>            <tr class="a">             <td>javascript (js)</td>             <td>jacl (jacl)</td>             <td>netrexx (nrx)</td>            </tr>            <tr class="b">             <td>java (java)</td>             <td>javaclass (class)</td>             <td>bml (bml)</td>            </tr>            <tr class="a">             <td>vbscript (vbs)</td>             <td>jscript (jss)</td>             <td>perlscript (pls)</td>            </tr>            <tr class="b">             <td>perl (pl)</td>             <td>jpython (py)</td>             <td>jython (py)</td>            </tr>            <tr class="a">             <td>lotusscript (lss)</td>             <td>xslt (xslt)</td>             <td>pnuts (pnut)</td>            </tr>            <tr class="b">             <td>beanbasic (bb)</td>             <td>beanshell (bsh)</td>             <td>ruby (rb)</td>            </tr>            <tr class="a">             <td>judoscript (judo, jud)</td>            </tr>            </thead>        </table>           <p>Once you have picked a language, you need to download its libraries and install it         into your application, which usually means copying its jar files into the same location        you copied the Struts Scripting jar.  If you are not sure, we recommend Groovy        which ships with the Struts Scripting Mailreader example, as it features a very similar Java-like syntax.        </p>        <p><i>Optional</i>: If you don't see your desired language that claims to support BSF,         or their BSF engine has changed from what BSF expects, you can manually define BSF         engines and have them loaded by Struts Scripting.          Create a file called          <code>struts-scripting.properties</code> and add two properties for each engine:          </p>          <ul>           <li><code>struts-scripting.engine.ENGINE_NAME.class</code> - The class of the BSF               engine where ENGINE_NAME is the name you are calling the engine.</li>           <li><code>struts-scripting.engine.ENGINE_NAME.extensions</code> - A comma-delimited               list of file extensions that will be used to identify the engine to use               to execute the script.</li>          </ul>        <p>The <code>struts-scripting.properties</code> should then stored in a directory        accessible to the classloader, usually <code>WEB-INF/classes</code>.        </p>    </div>         <div class="subsection"><a name="Usage"></a><h3>Usage</h3>      <a name="usage"></a>         <p>To determine what script will be executed, the "parameter" attribute of           the action mapping should contain the name of the script relative to           the web application root directory (i.e. http://server/app). In the place of          the traditional Action implementation, use the value <code>org.apache.struts.scripting.ScriptAction</code>.         For example:         </p><pre>    &lt;action    path="/logoff"               type="org.apache.struts.scripting.ScriptAction"               parameter="/WEB-INF/scripts/Logoff.bsh"&gt;      &lt;forward name="success"              path="/index.jsp"/&gt;    &lt;/action&gt;</pre>        <p>In addition to specifying the script file, the "parameter" attribute can        also contain parameters that will be passed to the script in the form of         pre-defined variables.  The format follows the URL format:</p><pre>    parameter="/path/file.bsh?PARAMETER_NAME=PARAMETER_VALUE[&amp;amp;PARAMETER_NAME=PARAMETER_VALUE..]"</pre>        <p>This ability to pass parameters can enable DispatchAction-type behavior where one script file            can handle multiple action paths.  If you are using Struts Action 1.3 or later, this feature            isn't as useful since you can pass multiple values through ActionMapping using the             <code>&lt;set-property key="foo" value="bar"&gt;</code> syntax.        </p>        <p>        Before the script completes, the next ActionForward needs to be        specified.  This can be done one of two ways:        </p>          <ol>           <li>Set <code>struts.forwardName</code> to the name of the forward</li>           <li>Set <code>struts.forward</code> to the actual ActionForward object              </li>          </ol>          <p>A number of pre-defined variables are available to the script:</p>          <ul>           <li><code>request</code> - The HTTP request</li>           <li><code>response</code> - The HTTP response</li>           <li><code>session</code> - The session</li>           <li><code>application</code> - The servlet context</li>           <li><code><a href="apidocs/org/apache/struts/scripting/StrutsInfo.html">struts</a></code>                 - A grouping of all Struts-related objects</li>           <li><code>log</code> - A logging instance</li>          </ul>          <p>          You can add your own variables by creating a BSFManagerFilter and          configuring it in struts-scripting.properties:          </p>          <ul>           <li><code>struts-scripting.filters.FILTER_NAME.class=FILTER_CLASS</code> - The               class implementing BSFManagerFilter where FILTER_NAME is the name you               are calling the filter.</li>           <li><code>struts-scripting.filters.FILTER_NAME.PROPERTY_NAME=PROPERTY_VALUE</code>                - A property to be used by the filter.</li>          </ul>      </div>   </div></div></div><div class="clear"><hr></hr></div><div id="footer"><div class="xright">

⌨️ 快捷键说明

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