struts-1 - Struts struts-config.xml Action 映射解释

标签 struts-1 struts-config jquery-ajax

我是 Struts 框架的菜鸟。我试图了解 Action 映射是如何工作的。假设我有一个发送 AJAX 请求的 JavaScript 文件:

$("button").click(function(){
    $.ajax({url: "myTestUrl.do", success: function(result){
        //do something with result
    });
});
和我的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>
我不明白 action 之间的关系和 form-bean .我的请求会由 TestAction 处理吗? ?如果是这样,表单 bean type 的用途是什么?属性?
更新 :
任何需要全面了解 struts MCV 框架的人,请查看 this关联。

最佳答案

该关系由 name 建立。 Action 配置中的属性。所以如果你使用 name="testForm"然后形成名称为 testForm 的 bean将被注入(inject)到 Action 的执行方法中。

如果相对 url 与操作配置中的路径值匹配并且您已将操作 servlet 映射到 *.do,则您的请求可能会被处理。在 servlet 映射模式中。
type <form-bean> 的属性用于输入可能会扩展 ActionForm 的 bean 类的 FQCN . Struts 需要它能够在需要时实例化 bean。

关于struts-1 - Struts struts-config.xml Action 映射解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36458341/

相关文章:

javascript - jsp中Select框处理一百万条记录的最佳方式

struts2 - struts 2包是否必须扩展 "struts-default"?

javascript - XMLHttpRequest 无法加载 Origin null 不允许 Access-Control-Allow-Origin

jsp - 未在操作中获取表单数据

javascript - Ajax - 按 Shopify/Liquid 中的价格过滤

java - 为什么 java 代码不将文本转换为 utf8 字符?

jakarta-ee - Struts 1.x 和 Struts 2.x 有什么区别

java - Action 类是否具有像formbean这样的范围

java - struts中的文件上传