【正文】
of the scope (request or session) within which the form bean, if any, associated with this mapping will be created. validate Set to true if the validate method of the form bean (if any) associated with this mapping should be called. input Contextrelative path of the input form to which control should be returned if 5 a validation error is encountered. This can be any URI: HTML, JSP, VM, or another Action Mapping. parameter Generalpurpose configuration parameter that can be used to pass extra information to the Action selected by this ActionMapping. attribute Name of the requestscope or sessionscope attribute under which our form bean is accessed, if it is other than the bean39。s specified name. prefix Prefix used to match request parameter names to form bean property names, if any. suffix Suffix used to match request parameter names when populating the properties of our ActionForm bean, if any. unknown Can be set to true if this mapping should be configured as the default for this application (to handle all requests not handled by another mapping). Only one mapping can be defined as the default unknown mapping within an application. forwards(s) Block of ActionForwards for this mapping to use, if any. exception(s) Block of ExceptionHandlers for this mapping to use, if any. Table The base ActionMapping properties (continued) Property Description Since Struts Since Struts 198 CHAPTER 7 Designing with ActionMappings Of course, it can still be useful to treat your ActionMappings as if they were part of a hierarchy and group related mands under the same folder. The only restriction is that the names must match whatever pattern is used in the application’s deployment description () for the ActionServlet. This is usually 6 either /do/* or *.do, but any similar pattern can be used. If you are working in a team environment, different team members can be given different ActionMapping namespaces to use. Some people may be working with the /customer ActionMappings, others may be working with the /vendor ActionMappings. This may also relate to the Java package hierarchy the team is using. Since the ActionMapping URIs are logical constructs, they can be anized in any way that suits your project. With Struts , these types of namespaces can be promoted to application modules. Each team can work independently on its own module, with its own set of configuration files and presentation pages. Configuring your application to use multiple modules is covered in chapter 4. DEFINITION The web runs on URIs, and most URIs map to physical files. If you want to change the resource, you change the corresponding file. Some URIs, like Struts actions, are virtual references. They do not have a corresponding file but are handled by a programming ponent. To change the resource, we change how the ponent is programmed. But since the path is a URI and interacts with other systems outside our control, the path is not a true logical reference—the name of an ActionForward, for instance. We can change the name of an ActionForward without consulting other systems. It’s an internal, logical reference. If we change the path to an ActionMapping, we might need to update other systems that refer to the ActionMapping through its public URI. The forward property When the forward property is specified, the servlet will not pass the request to an Action class but will make a call to . Since the operation does not use an Action class, it can be used to integrate Struts with other resources and to prototype systems. The forward, include, and type properties are mutually exclusive. (See chapter 6 for more information.) The include property When the include property is specified, the servlet will not pass the request to an Action class but will make a call to . The operation 7 ActionMapping properties 199 does not use an Action class and can be used to integrate Struts with other ponents. The forward, include, and type properties are mutually exclusive. (See chapter 6 for more information.) The type property Most mappings will specify an Action class type rather than a forward or include. An Action class may be used by more than one mapping. The mappings may specify form beans, parameters, forwards, or exceptions. The forward, include, and type properties are mutually exclusive. The className property When specified, className is the fully qualified Java classname of the ActionMapping subclass that should be used for this object. This allows you to use your own ActionMapping subclass with specialized methods and properties. See also section . The name property This property specifies the logical name for the form bean, as given in the formbean segment of the Struts configuration file. By default, this is also the name to be used when placing the form bean in the request or session context. Use the attribute property of this class to specify a different attribute key. The roles property This property is a madelimited list of the security role names that are allowed access to this ActionMapping object. By default, the same system that is used with standard containerbased security is applied to the list of roles given here. This means you can use actionbased security in lieu of specifying URL patterns in the deployment descriptor, or you can use both together. The security check is handled by the processRoles method of the Request Processor (). By subclassing RequestProcessor, you can also use the roles property with applicationbased security. See chapter 9 for more about subclassing RequestProcessor. The scope property The ActionForm bean can be stored in the current request or in the session scope (where it will be available to additional requests). While most developers use 8 request scope for the Actio