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

📄 newbie.html

📁 struts api,学习使用struts必备的文档
💻 HTML
字号:
<!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>Newbie FAQ - Apache Struts</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Ted Husted" name="author" />
<meta content="James Holmes" name="author" />
<meta content="Craig R. McClanahan" name="author" />
<meta content="Edgar Dollin" name="author" />
<meta content="James Turner" name="author" />
<meta content="Phil Steitz" 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>FAQs</p>
<ul>
        <li>
<a href="kickstart.html">Kickstart</a>
</li>
        <li>
<a href="newbie.html">Newbie</a>
</li>
        <li>
<a href="helping.html">How to Help</a>
</li>
    </ul>

    <p>Howto Guides</p>
<ul>
        <li>
<a href="actionForm.html">Action Forms</a>
</li>
        <li>
<a href="apps.html">Building Apps</a>
</li>
        <li>
<a href="database.html">Database</a>
</li>
        <li>
<a href="indexedprops.html">Indexed Properties</a>
</li>
        <li>
<a href="ssl.html">SSL</a>
</li>

        <li>
<a href="struts-el.html">Struts-EL (JSTL)</a>
</li>
    </ul>

    <p>IDE Guides</p>
<ul>
        <li>
<a href="eclipse.html">Eclipse</a>
</li>
        <li>
<a href="netbeans.html">Netbeans</a>
</li>
    </ul>

    <p>Quick Links</p>
<ul>
        <li>
<a href="../index.html">Welcome</a>
</li>

        <li>
<a href="../userGuide/index.html">User and Developer Guides</a>
</li>
    </ul>

<div class="authors">
<p>
<strong>Contributors</strong>
</p>
<ul>
<li>Ted Husted</li>
<li>James Holmes</li>
<li>Craig R. McClanahan</li>
<li>Edgar Dollin</li>
<li>James Turner</li>
<li>Phil Steitz</li>
</ul>
</div>
</div>
<!--end menu-->
<div id="main">
<h1 id="faq">Newbie FAQ</h1>
<h2 id="contents">Index</h2>
<div class="indent">

    <p>
    Here are answers to the most common questions people ask when using
    Struts on their first project.
    <strong>For an in-depth, searchable FAQ, visit our friends at
    <a href="http://www.jguru.com/faq/home.jsp?topic=Struts">JGuru</a>.</strong>
    </p>

    <ul>

    <li>
    <a href="#reload">Why was reload removed from Struts 1.1?</a>
    </li>

    <li>
    <a href="#modules">What is a modular application? What does
    module-relative mean?</a>
    </li>

    <li>
    <a href="#naming">Why are some of the class and element names
    counter-intuitive?</a>
    </li>

    <li>
    <a href="#actionForms">Whither ActionForms?</a>
    </li>

    <li>
    <a href="#actionFormInterface">Why is ActionForm a base class rather than an interface?</a>
    </li>

    <li>
    <a href="#multiple">Can I use multiple HTML form elements with the same
    name?</a>
    </li>

    <li>
    <a href="#multipleSubmits">Can I have multiple submit buttons on the same
    form?</a>
    </li>

    <li>
<a href="#checkbox">Why are my checkboxes not being set from ON to
    OFF?</a>
    </li>

    <li>
<a href="#focus">Why doesn't the focus feature on the &lt;html:form&gt;
    tag work in every circumstance?</a>
    </li>

    <li>
    <a href="#javascript.submit">How do I use JavaScript to submit a form? </a>
    </li>

    <li>
    <a href="#javascript">How do I use JavaScript to ... </a>
    </li>

    <li>
    <a href="#reset">Do I need to implement reset and set all my form
    properties to their initial values?</a>
    </li>

    <li>
    <a href="#scriptlets">Can't I just create some of my JavaBeans in the JSP
    using a scriptlet?</a>
    </li>

    <li>
    <a href="#otherBeans">Can I use other beans or hashmaps with ActionForms?</a>
    </li>

    <li>
    <a href="#tags">Why do the Struts tags provide for so little
    formatting?</a>
    </li>

    <li>
    <a href="#layout">Why don't the Struts taglibs offer more layout options?</a>
    </li>


    <li>
    <a href="#link">Why does the &lt;html:link&gt; tag URL-encode javascript and
    mailto links?"</a>
    </li>

    <li>
    <a href="#authenticate">How can I authenticate my users?</a>
    </li>

    <li>
    <a href="#pager">How can I scroll through list of pages like the search
    results in google?</a>
    </li>

    <li>
    <a href="#minimization">Why does the option tag render selected="selected"
    instead of just "selected"?
    </a>
</li>

    <li>
<a href="#jsp">Do I have to use JSPs with my application?</a>
</li>

    <li>
    <a href="#formbeans">Do ActionForms have to be true JavaBeans?</a>
    </li>

    <li>
    <a href="#separate">Do I have to have a separate ActionForm bean
    for every HTML form?</a>
    </li>

    <li>
    <a href="#prepopulate">How can I prepopulate a form?</a>
    </li>

    <li>
    <a href="#noForm">Can I have an Action without a form?</a>
    </li>

    <li>
    <a href="#requiredif">Can you give me a simple example of using the requiredif Validator rule?</a>
    </li>

    <li>
    <a href="#validate">When is the best time to validate input?</a>
    </li>

    <li>
    <a href="#avoidValidate">How can I avoid validating a form before data is entered?</a>
    </li>

    <li>
    <a href="#wizard">How can I create a "wizard" workflow?</a>
    </li>

    <li>
    <a href="#chaining">How can I "chain" Actions?</a>
    </li>

    </ul>

    <p>
    If you like to <a href="helping.html">contribute</a>,
    there is a list of <a href="#undocumented"> undocumented questions</a>
    at the end of this page.
    </p>

</div>
<h2 id="reload">Why was reload removed from Struts (since 1.1)?</h2>
<div class="indent">

<p>
The problem with ReloadAction was that Struts was trying to act like a
container, but it couldn't do a proper job of it. For example, you
can't reload classes that have been modified, or (portably) add new
classes to a running web application (even if the container supported it).
</p>

<p>
Meanwhile, as Struts 1.1 was being developed, work progressed on things
like Tomcat's reload command via the Manager webapp. This feature allows
you to quickly reload-on-demand, complete with saving and restoring your
session). It started to make even less sense for Struts to half-implement
a feature that containers are implementing fully.
</p>

<p>
A more minor point is that freezing the configuration information at application
startup time allows Struts to safely access the mapping information without
bothering with synchronization. The "startup-only" strategy creates a modest
but real improvement in performance for all users.
</p>

<p>So, ReloadAction is not supported since Struts 1.1 for two reasons:</p>

<ul>
<li>
    It never did let you reload everything that you would really
    want to -- particularly changed classes -- so many people
    ended up having to reload the webapp anyway.
</li>
<li>
    Containers are starting to offer reload-on-demand features
    which does the same thing as the Struts ReloadAction, only better.
</li>
<li>
    Not supporting ReloadAction lets Struts avoid doing synchronization
    locks around all the lookups (like figuring out which action to use,
    or the destination of an ActionForward) so applications can run a
    little faster.
</li>
</ul>

<p>
Of course, if someone came up with an implementation that solved these
problems without creating any others, we would not be opposed to including
a new ReloadAction.
</p>

</div>
<h2 id="modules">What is a modular application? What does module-relative mean?</h2>
<div class="indent">

<p>
Since Struts 1.1, the framework supports multiple application modules. All applications have at
least one root, or default, module. Like the root directory in a file system, the default application
has no name. (Or is named with an empty string, depending your viewpoint.) Developing an application
with only a default module is no different from how applications were developed under Struts 1.0.
Since Struts 1.1, you can add additional modules to your application, each of which can have their
own configuration files, messages resources, and so forth. Each module is developed in the same way as
the default module. Applications that were developed as a single module can added to a multiple
module application, and modules can promoted to a standalone application without change. For more
about configuring your application to support multiple modules, see
<a href="../userGuide/configuration.html#dd_config_modules">Configuring Applications</a> in the
User Guide.
</p>

<p>
But to answer the question =:0), a modular application is a Struts application that uses more than
one module. Module-relative means that the URI starts at the module level, rather than at
the context level, or the absolute-URL level.
</p>
<ul>
<li>Absolute URL: http://localhost/myApplication/myModule/myAction.do</li>
<li>context-relative: /myModule/myAction.do</li>
<li>module-relative: /myAction.do</li>
</ul>

<p>
    The Struts Examples application is a modular application that was assembled from several
    applications that were created independently.
</p>

</div>
<h2 id="naming">Why are some of the class and element names counter-intuitive?</h2>
<div class="indent">
<p>
The framework grew in the telling and, as it evolved, some of the names
drifted.
</p>
<p>The good thing about a nightly build, is that everything becomes
available to the community as soon as it is written. The bad thing about
a nightly build is that things like class names get locked down early and
then become difficult to change.
</p>
</div>
<h2 id="actionForms">Wither ActionForms?</h2>
<div class="indent">
<p>
<a href="http://www.mail-archive.com/struts-user@jakarta.apache.org/msg19281.html">http://www.mail-archive.com/struts-user@jakarta.apache.org/msg19281.html</a>
<br />
<a href="http://www.mail-archive.com/struts-user@jakarta.apache.org/msg19338.html">http://www.mail-archive.com/struts-user@jakarta.apache.org/msg19338.html</a>
<br />
<a href="http://www.mail-archive.com/struts-user@jakarta.apache.org/msg20833.html">http://www.mail-archive.com/struts-user@jakarta.apache.org/msg20833.html</a>
<br />
</p>
</div>
<h2 id="actionFormInterface">Why is ActionForm a base class rather than an interface?</h2>
<div class="indent">
<p>
The MVC design pattern is very simple to understand but much more difficult
to live with.  You just need this little bit of Business Logic in the View
logic or you need just that little bit of View logic in the Business tier and
pretty soon you have a real mess.
</p>
<p>
Making ActionForm a class takes advantage of the single
inheritance restriction of Java to it makes it more difficult for people to do
things that they should not do.
</p>
<p>
ActionForms implemented as interfaces encourage making the property types match
the underlying business tier instead of Strings, which violates one of the
primary purposes for ActionForms in the first place (the ability to reproduce
invalid input, which is a fundamental user expectation).
ActionForms as an interface would also encourage using existing DAO objects as
ActionForms by adding 鈥榠mplements ActionForm鈥

⌨️ 快捷键说明

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