官方Class LookupDispatchAction说明文档(转)

<!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== -->

org.apache.struts.actions
<script type="text/javascript"> <!-- google_ad_client = "pub-0139896083561460"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text"; google_ad_channel =""; google_color_border = "870100"; google_color_bg = "FFFFFF"; google_color_link = "0033FF"; google_color_url = "999999"; google_color_text = "FF0099"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>
Class LookupDispatchAction


<script type="text/javascript"> <!-- google_ad_client = "pub-0139896083561460"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text"; google_ad_channel =""; google_color_border = "870100"; google_color_bg = "FFFFFF"; google_color_link = "0033FF"; google_color_url = "999999"; google_color_text = "FF0099"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>
java.lang.Object extended by org.apache.struts.action.Action extended by org.apache.struts.actions.DispatchAction extended by org.apache.struts.actions.LookupDispatchAction
 

public abstract class LookupDispatchAction extends DispatchAction

<script type="text/javascript"><!-- google_ad_client = "pub-0139896083561460"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text"; google_ad_channel =""; google_color_border = "870100"; google_color_bg = "FFFFFF"; google_color_link = "0033FF"; google_color_url = "999999"; google_color_text = "FF0099"; //--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
An abstract Action that dispatches to the subclass mapped execute method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping. To configure the use of this action in your struts-config.xml file, create an entry like this:

   <action path="/test"
      type="org.example.MyAction"
      name="MyForm"
      scope="request"
      input="/test.jsp"
      parameter="method"/>

which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties:

    button.add=Add Record    button.delete=Delete Record  

And your JSP would have the following format for submit buttons:

   <html:form action="/test">
   <html:submit property="method">
    <bean:message key="button.add"/>
</html:submit>
<html:submit property="method">
   <bean:message key="button.delete"/>
</html:submit> </html:form>

Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are:

  protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.add", "add");
map.put("button.delete", "delete");
return map;
}
public ActionForward add(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
// do add
return mapping.findForward("success");
}
public ActionForward delete(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
// do delete
return mapping.findForward("success");
}

Notes - If duplicate values exist for the keys returned by getKeys,
only the first one found will be returned. If no corresponding key is found
then an exception will be thrown. You can override the method unspecified to
provide a custom handler. If the submit was cancelled (a html:cancel button
was pressed), the custom handler cancelled will be used instead.


<!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- -->

Field Summary
protected  java.util.Map keyMethodMap
          Resource key to method name lookup.
protected  java.util.Map localeMap
          Reverse lookup map from resource value to resource key.
  <!-- -->
Fields inherited from class org.apache.struts.actions.DispatchAction
clazz, log, messages, methods, types
  <!-- -->
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 <!-- ======== CONSTRUCTOR SUMMARY ======== --> <!-- -->
Constructor Summary
LookupDispatchAction()
           
 <!-- ========== METHOD SUMMARY =========== --> <!-- -->
Method Summary
 ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it).
protected abstract  java.util.Map getKeyMethodMap()
          Provides the mapping from resource key to method name.
protected  java.lang.String getLookupMapName(javax.servlet.http.HttpServletRequest request, java.lang.String keyName, ActionMapping mapping)
          Lookup the method name corresponding to the client request's locale.
protected  java.lang.String getMethodName(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String parameter)
          Returns the method name, given a parameter's value.
private  java.util.Map initLookupMap(javax.servlet.http.HttpServletRequest request, java.util.Locale userLocale)
          This is the first time this Locale is used so build the reverse lookup Map.
  <!-- -->
Methods inherited from class org.apache.struts.actions.DispatchAction
cancelled, dispatchMethod, getMethod, unspecified
  <!-- -->
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
  <!-- -->
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

<!-- ============ FIELD DETAIL =========== --><!-- -->

Field Detail
<!-- -->

localeMap

protected java.util.Map localeMap
Reverse lookup map from resource value to resource key.


<!-- -->

keyMethodMap

protected java.util.Map keyMethodMap
Resource key to method name lookup.

<!-- ========= CONSTRUCTOR DETAIL ======== --> <!-- -->
Constructor Detail
<!-- -->

LookupDispatchAction

public LookupDispatchAction()
<!-- ============ METHOD DETAIL ========== --> <!-- -->
Method Detail
<!-- -->

execute

public execute( mapping,
 form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
Process the specified HTTP request, and create the corresponding HTTP
response (or forward to another web component that will create it).
Return an ActionForward instance describing where and how control should
be forwarded, or null if the response has already been completed.

Overrides:
execute in class DispatchAction
Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing
response - The HTTP response we are creating
form - The optional ActionForm bean for this request (if any)
Returns:
Describes where and how control should be forwarded.
Throws:
java.lang.Exception - if an error occurs

<!-- -->

initLookupMap

private java.util.Map initLookupMap(
                                 javax.servlet.http.HttpServletRequest request,
java.util.Locale userLocale)
This is the first time this Locale is used so build the reverse lookup Map.
Search for message keys in all configured MessageResources for the current
module.


<!-- -->

getKeyMethodMap

protected abstract java.util.Map getKeyMethodMap()
Provides the mapping from resource key to method name.

Returns:
Resource key / method name map.

<!-- -->

getLookupMapName

protected java.lang.String getLookupMapName(
                        javax.servlet.http.HttpServletRequest request,
java.lang.String keyName,
 mapping)
throws javax.servlet.ServletException
Lookup the method name corresponding to the client request's locale.

Parameters:
request - The HTTP request we are processing
keyName - The parameter name to use as the properties key
mapping - The ActionMapping used to select this instance
Returns:
The method's localized name.
Throws:
javax.servlet.ServletException - if keyName cannot be resolved
Since:
Struts 1.2.0

<!-- -->

getMethodName

protected java.lang.String getMethodName( mapping,
 form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String parameter)
throws java.lang.Exception
Returns the method name, given a parameter's value.

Overrides:
getMethodName in class DispatchAction
Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The HTTP request we are processing
response - The HTTP response we are creating
parameter - The ActionMapping parameter's name
Returns:
The method's name.
Throws:
java.lang.Exception
Since:
Struts 1.2.0
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== --> <!-- -->
<!-- ======== END OF BOTTOM NAVBAR ======= --> Copyright © 2000-2004 - The Apache Software Foundation

<!-- Body End --><script language="javascript" src="bodyend.js"></script><script src="http://www.google-analytics.com/urchin.js" defer type="text/javascript"></script><script defer type="text/javascript"><![CDATA[uacct = "UA-469010-2";urchinTracker();]]></script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值