Struts struts-config.xml动作映射说明

Tom*_* O. 5 struts-1 struts-config

我对Struts框架不熟悉。我试图了解动作映射的工作原理。假设我有一个发送AJAX请求的JavaScript文件:

$("button").click(function(){
    $.ajax({url: "myTestUrl.do", success: function(result){
        //do something with result
    });
});
Run Code Online (Sandbox Code Playgroud)

我的struts-config.xml文件如下所示:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
    <form-beans>
        <form-bean name="testForm" type="com.test.TestForm"/>       
    </form-beans>

    <!-- Global Forwards -->    
    <global-forwards>
    </global-forwards>

    <!-- Action Mappings -->
    <action-mappings>

        <action path="/myTestUrl" 
                type="com.test.TestAction" 
                name="testForm" 
                scope="request" />

    </action-mappings>
    <controller locale="true"/>
</struts-config>
Run Code Online (Sandbox Code Playgroud)

我不明白之间的关系actionform-bean。我的请求会由处理TestAction吗?如果是这样,那么表单bean type属性的目的是什么?

更新

对于需要全面了解Struts MCV框架的任何人,请查看以下链接:http : //www.javaranch.com/journal/2002/03/newslettermar2002.jsp#struts

Rom*_*n C 5

该关系由name操作配置中的属性建立。因此,如果您使用name="testForm"then 具有名称的表单 beantestForm将被注入到操作的执行方法中。

如果相对 url 与操作配置中的路径值匹配,并且您已将操作 servlet 映射到*.doservlet 映射模式中,则可能会处理您的请求。

type属性<form-bean>用于输入可能扩展ActionForm. Struts 需要它能够在需要时实例化一个 bean。