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

📄 faq.fml

📁 structs源码
💻 FML
📖 第 1 页 / 共 2 页
字号:
                </p>
                <source>
                    class MyAction extends ActionForm implements Serializable
                    {

                    public ActionForward execute (ActionMapping map,
                    ActionForm form,
                    HttpServletRequest req, HttpServletResponse) {

                    String myAction = req.getParameter("myAction");

                    if (myAction.equals("save") {
                    // ... save action ...
                    } else if (myAction.equals("delete") {
                    // ... delete action ...
                    }
                    }
                    }
                    }
                </source>
                <p>
                    This is just one of many ways to achieve submitting a form
                    and decoding the
                    intended action. Once you get used to the framework you
                    will find other ways
                    that make more sense for your coding style and
                    requirements. Just remember
                    this example is completely non-functional without
                    JavaScript.
                </p>
                <p>
                    Here is a link
                    which utilizes the LookupDispatch action to submit forms
                    with multiple actions
                    without javascript:
                    <a href="http://husted.com/struts/tips/003.html">
                        http://husted.com/struts/tips/003.html</a>
                </p>
                </answer>
             </faq>                

            <faq id="javascript">
                <question>
                How do I use JavaScript to ...
                </question>
                <answer>
                <p>
                    The framework is mainly a server-side technology.
                    We bundled in some JSP tags to expose the framework
                    components to your
                    presentation page, but past that, the usual development
                    process applies.
                </p>

                <p>
                    Interactive pages require the use of JavaScript.
                    (That's why it was invented.)
                    If you want things popping up or doing this when they
                    click that,
                    you are outside the scope of the framework and back into the web
                    development mainstream.
                </p>

                <p>
                    You use JavaScript with the framework the same way you use with
                    any presentation
                    page.
                    Since JavaScript is a client-side technology, you can use
                    simple relative
                    references to your scripts.
                    If you need to fire a JavaScript from a HTML control, the
                    Struts HTML tags
                    have properties for the JavaScript events.
                </p>

                <p>
                    A very good JavaScript resource is Matt Kruse's site at
                    <a href="http://www.mattkruse.com/javascript/">
                        http://www.mattkruse.com/javascript/</a>
                </p>                
                </answer>
             </faq>                

            <faq id="reset">
                <question>
                Do I need to implement reset and set all my form properties to their initial values?
                </question>
                <answer>
                <p>
                    No.
                    You need to set checkbox properties to false if the
                    ActionForm is being retained in session scope.
                    This is because an unchecked box does not submit an
                    attribute.
                    Only checked boxes submit attributes.
                    If the form is in session scope, and the checkbox was
                    checked, there is no way to turn it back off without the
                    reset method.
                    Resetting the properties for other controls, or for a
                    request scope form, is pointless.
                    If the form is in request scope, everything already just
                    started at the initial value.
                </p>                
                </answer>
             </faq>                

            <faq id="scriptlets">
                <question>
                Can't I just create some of my JavaBeans in the JSP using a scriptlet?
                </question>
                <answer>
                <p>
                    The framework is designed to encourage a
                    <a href="http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html">
                        Model 2/MVC architecture</a>
                    . But there is nothing that prevents you from using Model
                    1
                    techniques in your JavaServer Pages, so the answer to the
                    question is "Yes, you can".
                </p>
                <p>
                    Though, using Model 1 techniques in a framework application
                    does go against the grain.
                    The approach recommended by most developers is to
                    create and populate whatever
                    objects the view may need in the Action, and then forward
                    these through the request.
                    Some objects may also be created and stored in the session
                    or context,
                    depending on how they are used.
                </p>
                <p>
                    Likewise, there is nothing to prevent you from using
                    scriptlets along with JSP tags in your pages. Though, 
                    many developers report
                    writing very complex
                    scriplet-free applications and recommend the JSP tag
                    approach to others.
                </p>
                <p>
                    For help with Model 1 techniques and scriptlets, you might
                    consider joining the
                    <a href="http://archives.java.sun.com/jsp-interest.html">
                        Javasoft JSP-interest
                        mailing list,</a>
                    where there are more people still using these
                    approaches.
                </p>                </answer>
             </faq>                

            <faq id="link">
                <question>
                Why does the &lt;html:link> tag URL-encode javascript and mailto links?
                </question>
                <answer>
                <p>
                    The &lt;html:link> tag is not intended for use with
                    client-side references like those used to launch
                    Javascripts or email clients.
                    The purpose of link tag is to interject the context (or
                    module) path into the URI so that your server-side links
                    are not dependent on your context (or module) name.
                    It also encodes the link, as needed, to maintain the
                    client's session on the server.
                    Neither feature applies to client-side links, so there is
                    no reason to use the &lt;html:link> tag.
                    Simply markup the client-side links using the standard
                    <a/>
                    tag.
                </p>                
                </answer>
             </faq>                

            <faq id="pager">
                <question>
                How can I scroll through list of pages like the search results in Google?
                </question>
                <answer>
                <p>Many Struts developers use the Pager from the JSPTags
                    site.</p>
                <p>
                    <a href="http://jsptags.com/tags/navigation/pager/">
                        http://jsptags.com/tags/navigation/pager/</a>
                </p>                
                </answer>
             </faq>                
             

            <faq id="minimization">
                <question>
                Why does the option tag render selected=selected instead of just selected?
                </question>
                <answer>
                <p>
                    Attribute minimization (that is, specifying an attribute
                    with no value) is
                    a place where HTML violates standard XML syntax rules.
                    This matters a lot
                    for people writing to browsers that support XHTML, where
                    doing so makes
                    the page invalid.It's much better for Struts to use the
                    expanded syntax,
                    which works the same on existing browsers interpreting
                    HTML, and newer
                    browsers that expect XHTML-compliant syntax. Struts is
                    following the
                    behavior recommended by the
                    <a href="http://www.w3.org/TR/xhtml1/#h-4.5">
                        XHTML specification</a>
                </p>
                </answer>
             </faq>                

            <faq id="tags">
                <question>
                Why does Struts Taglib provide for so little formatting?
                </question>
                <answer>
                <p>
                    <em>The Struts tags seem to provide only the most
                        rudimentary functionality.
                        Why is there not better support for date formatting
                        and advanced string handling?</em>
                </p>
                <p>
                    Three historical reasons:
                </p>
                <p>
                    First, work started on the JSTL and we didn't want to
                    duplicate the effort.
                </p>
                <p>
                    Second, work started on Java Server Faces, and we didn't
                    want to duplicate that effort either.
                </p>
                <p>
                    Third, in a Model 2 application, most of the formatting
                    can be handled in the ActionForms (or in the business
                    tier),
                    so all the tag has to do is spit out a string.
                    This leads to better reuse since the same "how to format"
                    code does not need to be repeated in every instance.
                    You can "say it once" in a JavaBean and be done with it.
                </p>                
                </answer>
             </faq>                
             

            <faq id="layout">
                <question>
                Why doesn't Struts Taglib offer more layout options?
                </question>
                <answer>
                <p>
                    For more flexible placement of error messages,
                    try the
                    <a href="http://www.rabago.net/struts/html2/">&lt;html2&gt;</a>
                    Tag Library for Struts.
                </p>
                <p>
                    Since the Struts tags are open source, you can extend them
                    to provide whatever additional formatting you may need.
                    If you are interested in a pre-written taglib that offers
                    more layout options, see the
                    <a href="http://struts.application-servers.com">
                        struts-layout taglib</a>
                    .
                </p>
                <p>
                    In the same arena, there is a well regarded contributor
                    taglib that can help you create
                    <a href="http://sourceforge.net/projects/struts-menu/">
                        Menus for your Struts applications.</a>
                </p>
                <p>
                    Another very popular tag library is
                    <a href="http://displaytag.sourceforge.net">DisplayTag.</a>
                    .
                    DisplayTag is an excellent choice when you have tabular
                    data to present.
                </p>
                
                </answer>
             </faq>                

            <faq id="undocumented">
                <question>
                If you would like to contribute, here is a list of
    popular but undocumented questions
                </question>
                <answer>
                <ul>

                    <li>Why do my option lists disappear when validation
                        fails?</li>

                    <li>Why can't I disable URL-encoding in the Struts
                        taglibs?</li>

                </ul>                
                </answer>
            </faq>
        </part>
</faqs>

⌨️ 快捷键说明

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