org.apache.struts2.dispatcher.mapper
类 DefaultActionMapper

java.lang.Object
  继承者 org.apache.struts2.dispatcher.mapper.DefaultActionMapper
所有已实现的接口:
ActionMapper
直接已知子类:
PrefixBasedActionMapper, Restful2ActionMapper

public class DefaultActionMapper
extends Object
implements ActionMapper

Default action mapper implementation, using the standard *.[ext] (where ext usually "action") pattern. The extension is looked up from the Struts configuration key struts.action.extension.

To help with dealing with buttons and other related requirements, this mapper (and other ActionMappers, we hope) has the ability to name a button with some predefined prefix and have that button name alter the execution behaviour. The four prefixes are:

In addition to these four prefixes, this mapper also understands the action naming pattern of foo!bar in either the extension form (eg: foo!bar.action) or in the prefix form (eg: action:foo!bar). This syntax tells this mapper to map to the action named foo and the method bar.

Method Prefix

With method-prefix, instead of calling baz action's execute() method (by default if it isn't overriden in struts.xml to be something else), the baz action's anotherMethod() will be called. A very elegant way determine which button is clicked. Alternatively, one would have submit button set a particular value on the action when clicked, and the execute() method decides on what to do with the setted value depending on which button is clicked.

  <!-- START SNIPPET: method-example -->
  <s:form action="baz">
      <s:textfield label="Enter your name" name="person.name"/>
      <s:submit value="Create person"/>
      <s:submit method="anotherMethod" value="Cancel"/>
  </s:form>
  <!-- END SNIPPET: method-example -->
 
Action prefix

With action-prefix, instead of executing baz action's execute() method (by default if it isn't overriden in struts.xml to be something else), the anotherAction action's execute() method (assuming again if it isn't overriden with something else in struts.xml) will be executed.

  <!-- START SNIPPET: action-example -->
  <s:form action="baz">
      <s:textfield label="Enter your name" name="person.name"/>
      <s:submit value="Create person"/>
      <s:submit action="anotherAction" value="Cancel"/>
  </s:form>
  <!-- END SNIPPET: action-example -->
 


构造方法摘要
DefaultActionMapper()
           
 
方法摘要
 ActionMapping getMapping(javax.servlet.http.HttpServletRequest request, com.opensymphony.xwork2.config.ConfigurationManager configManager)
          Expose the ActionMapping for the current request
 ActionMapping getMappingFromActionName(String actionName)
          Expose the ActionMapping for the specified action name
 String getUriFromActionMapping(ActionMapping mapping)
          Convert an ActionMapping into a URI string
 void handleSpecialParameters(javax.servlet.http.HttpServletRequest request, ActionMapping mapping)
          Special parameters, as described in the class-level comment, are searched for and handled.
 boolean isSlashesInActionNames()
           
 void setAllowActionCrossNamespaceAccess(String allowActionCrossNamespaceAccess)
           
 void setAllowActionPrefix(String allowActionPrefix)
           
 void setAllowDynamicMethodCalls(String allow)
           
 void setAllowedActionNames(String allowedActionNames)
           
 void setAlwaysSelectFullNamespace(String val)
           
 void setContainer(com.opensymphony.xwork2.inject.Container container)
           
 void setExtensions(String extensions)
           
 void setSlashesInActionNames(String allow)
           
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

DefaultActionMapper

public DefaultActionMapper()
方法详细信息

setAllowDynamicMethodCalls

public void setAllowDynamicMethodCalls(String allow)

setSlashesInActionNames

public void setSlashesInActionNames(String allow)

setAlwaysSelectFullNamespace

public void setAlwaysSelectFullNamespace(String val)

setAllowedActionNames

public void setAllowedActionNames(String allowedActionNames)

setAllowActionPrefix

public void setAllowActionPrefix(String allowActionPrefix)

setAllowActionCrossNamespaceAccess

public void setAllowActionCrossNamespaceAccess(String allowActionCrossNamespaceAccess)

setContainer

public void setContainer(com.opensymphony.xwork2.inject.Container container)

setExtensions

public void setExtensions(String extensions)

getMappingFromActionName

public ActionMapping getMappingFromActionName(String actionName)
从接口 ActionMapper 复制的描述
Expose the ActionMapping for the specified action name

指定者:
接口 ActionMapper 中的 getMappingFromActionName
参数:
actionName - The name of the action that may have other information embedded in it
返回:
The appropriate action mapping

isSlashesInActionNames

public boolean isSlashesInActionNames()

getMapping

public ActionMapping getMapping(javax.servlet.http.HttpServletRequest request,
                                com.opensymphony.xwork2.config.ConfigurationManager configManager)
从接口 ActionMapper 复制的描述
Expose the ActionMapping for the current request

指定者:
接口 ActionMapper 中的 getMapping
参数:
request - The servlet request
configManager - The current configuration manager
返回:
The appropriate action mapping or null if mapping cannot be determined

handleSpecialParameters

public void handleSpecialParameters(javax.servlet.http.HttpServletRequest request,
                                    ActionMapping mapping)
Special parameters, as described in the class-level comment, are searched for and handled.

参数:
request - The request
mapping - The action mapping

getUriFromActionMapping

public String getUriFromActionMapping(ActionMapping mapping)
从接口 ActionMapper 复制的描述
Convert an ActionMapping into a URI string

指定者:
接口 ActionMapper 中的 getUriFromActionMapping
参数:
mapping - The action mapping
返回:
The URI string that represents this mapping