`
hilly
  • 浏览: 50595 次
  • 性别: Icon_minigender_1
  • 来自: **
社区版块
存档分类
最新评论

官方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 byorg.apache.struts.action.Actionextended byorg.apache.struts.actions.DispatchActionextended byorg.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 ActionForwardexecute(ActionMapping mapping,
ActionForm 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,
ActionMapping 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(ActionMapping mapping,
ActionForm 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>
分享到:
评论

相关推荐

    LookupDispatchAction 是使用方法

    public class LookupDispatchAction extends DispatchAction { public ActionForward method1(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ...

    DispatchAction、LookupDispatchAction、SwitchAction的应用

    ### DispatchAction、LookupDispatchAction、SwitchAction 的应用详解 #### 一、DispatchAction 的应用 **DispatchAction** 是 Struts 框架中一个非常有用的类,它位于 `org.apache.struts.actions` 包中。其核心...

    Struts(二)List_Map_LookupDispatchAction_Validate

    在Struts框架中,`List_Map_LookupDispatchAction_Validate`涉及了几个关键概念,我们将逐一详细解释。 1. **LookupDispatchAction**: 这是Struts1中的一个特殊类型的动作,主要用于处理多个请求映射到同一个Action...

    LookUpDispachAction的用法详解

    public class LookupDispatchAction extends DispatchAction { public ActionForward _add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ...

    学习struts很好的文档

    - **LookupDispatchAction**:用于查找和分发请求。 - **SwitchAction**:基于条件进行分发。 ##### 4.ActionForward类 表示Action执行后需要转向的目标页面或资源。 ##### 5.ActionForm类 封装了用户表单数据,...

    J2EE_高级Action

    public class LoginRegisterAction extends LookupDispatchAction { private String button; public String getButton() { return button; } public void setButton(String button) { this.button = button;...

    struts 1的标签的用法详细

    LookupDispatchAction 与`DispatchAction`类似,但提供了更灵活的请求参数到方法映射方式,通常用于基于选择项的分发。 #### 5. ActionMapping 封装了请求到Action的映射信息,包括Action类、ActionForm、结果页面...

    struts LookupdispathAction类使用实例

    Struts LookupDispatchAction 类是Apache Struts 框架中的一种高级控制器,它扩展了`DispatchAction`类,提供了一种更加灵活的方式来处理请求映射。在 Struts 框架中,Action 是业务逻辑的核心组件,负责接收HTTP...

    基于JAVA SMART系统-系统框架设计与开发(源代码+论文).zip

    因此,在对本系统进行架构设计的时候,考虑建立一个抽象的BaseAction类,该类继承LookupDispatchAction,实现LookupDispatchAction类中的getKeyMethodMap方法,在方法中返回本系统中请求参数值与资源文件中参数值的...

    JavaEE框架 Struts_In_Action(中文版)

    JavaEE框架 Struts_In_Action(中文版) Struts Action Struts_In_Action LookupDispatchAction DispatchAction 对Action讲的比较仔细,可以深入的了解Struts框架里的基本原理。

    struts2.0之action

    Struts 2.0还提供了一种方式来改变默认调用的方法,这类似于Struts 1.x的`LookupDispatchAction`。在`struts.xml`中,可以直接指定Action的执行方法,例如: ```xml &lt;action name="HelloWorld" class="tutorial....

    struts1深入学习

    struts1学习资料:里面包含struts源码工程 ActionServlet DispatchAction Action LookUpDispatchAction的用法 还包含html logic bean tiles标签的详细使用方法和validate验证框架的具体案例

    java处理一个form多个submit

    在 Struts1 中,使用 LookupDispatchAction 动作可以处理含有多个 submit 的 form。但是,这种方式需要访问属性文件,还需要映射,比较麻烦。从 Struts1.2.9 开始,加入了 EventDispatchAction 动作,该类可以通过 ...

    轻量级J2EE企业应用实战源码 3 下

    1. **LookupDispatchAction**: 这个文件可能涉及到Struts框架中的`LookupDispatchAction`,这是一个用于处理多视图的Action,它可以根据用户请求的参数来决定调用哪个业务方法。这在实现复杂的视图跳转和逻辑控制时...

    Struts2教程:处理一个form多个submit.doc

    在处理一个表单(form)中存在多个submit按钮的情况时,Struts2提供了一种优雅的方式来区分用户点击了哪个按钮,而无需像Struts1那样使用额外的动作类(如LookupDispatchAction或EventDispatchAction)。 在传统的...

    struts1.x技术课程讲解.pdf

    - **LookUpDispatchAction**:与 DispatchAction 类似,但更灵活,可以动态地确定方法名。 2. **ActionServlet**:Struts1.x 的核心组件,负责初始化框架、接收 HTTP 请求并将请求分发给相应的 Action 类处理。 3. ...

    struts1.x和mysql整合的登陆例子

    在这个例子中,可能会使用`LookupDispatchAction`,这是一个特殊类型的Action,它允许根据用户提交的按钮值(submit标签的name属性)来调用不同的业务方法。 在用户界面设计中,静态验证是先于服务器端验证的一步,...

    EventDispatchAction类处理一个form多个submit

    与`LookupDispatchAction`相比,它的使用更为便捷,无需与属性文件关联,也不需要手动在`getKeyMethodMap`方法中进行key和Action方法的映射。 #### 三、EventDispatchAction的工作原理 `EventDispatchAction`通过`...

    轻量级J2EE企业应用实战——Struts+Spring+Hibernate整合开发 源码第二部分

    `DispatchAction`和`LookupDispatchAction`是Struts中的特殊动作,前者允许基于请求参数来调用不同的方法,后者则是在`DispatchAction`基础上进一步细化,根据请求的参数值查找并执行相应的方法。 `DynaActionForm`...

Global site tag (gtag.js) - Google Analytics