Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A web application uses a deployment descriptor to initialize resources like filters and listeners. The web deployment descriptor is formatted as a XML document and named web.xml. Likewise, the framework uses Struts can either initializes its resources by scanning your classes using Java packages declared in this web.xml file, or you can have full control over the configuration via a configuration file, named struts.xml, to initialize its own resources. These resources include action mappings, to direct input to server-side Action classes, and result types, to select output pages.

Here's a typical configuration (struts.xml) for a login workflow:

Code Block
<struts>
    <include file="struts-default.xml"/>

    <package name="default" extends="struts-default">

        <action name="Logon" class="mailreader2.Logon">
            <result name="input">/pages/Logon.jsp</result>
            <result name="cancel" type="redirect-action">Welcome</result>
            <result type="redirect-action">MainMenu</result>
            <result name="expired" type="chain">ChangePassword</result>
        </action>

        <action name="Logoff" class="mailreader2.Logoff">
            <result type="redirect-action">Welcome</result>
        </action>

    </package>
</struts>

...